Skip to content

Commit

Permalink
Merge branch 'release-1.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
mcvaneede committed Feb 20, 2015
2 parents f58ba0c + 8bb5556 commit 2c090e1
Show file tree
Hide file tree
Showing 16 changed files with 229 additions and 286 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*~
*\#
\.\#*
\.swp
*\.swp
*\.pyc
22 changes: 22 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
New in Version 1.12
===================
* LSQ6 (MBM) fixes to the combination of --no-nuc and --inormalize. This would incorrectly apply the lsq6 transformation to the inormalized file twice
* MAGeT -- now uses the pipeline_name argument -- has better error messages when there are issues with the atlases/labels/masks -- if no atlases are found in the atlas library, the program exists -- has an explicit way to specify --pairwise
* improvements to error handling in the code
* most pipeline related files and directories are now prefixed with the pipeline name
* fixes to how the initial model is used. Now there are two possible scenarios:

image.mnc
image_mask.mnc

or

image.mnc
image_mask.mnc
image_native.mnc
image_native_mask.mnc
image_native_to_standard.xfm

* debug statements added in order to inspect heartbeat issues -- heartbeat checking can also be turned off at the moment
* on SciNet, as many executors as possible will start with the server using syncwith rather than after (in qsub)

New in Version 1.11
===================
(in addition to the changes in the alpha version)
Expand Down
29 changes: 20 additions & 9 deletions applications/MAGeT.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ def run(self):
print "You can find the default MAGeT protocols in your pydpiper source directory, in: applications_testing/test_data/"
sys.exit()


# There are two variables that can be used to determine where the output
# of the pipeline is stored: pipeline_name and outputDir
# If the outputDir is not specified, the current working directory is used.
if self.options.pipeline_name:
self.outputDir += "/" + self.options.pipeline_name
fh.makedirsIgnoreExisting(self.outputDir)

atlasDir = fh.createSubDir(self.outputDir, "input_atlases")

"""Read in atlases from directory specified in --atlas-library and
Expand All @@ -72,14 +78,13 @@ def run(self):
else:
average.append(abspath(inFile))
# check to make sure len(average)==len(labels)
if not len(average) == len(labels):
logger.error("Number of input atlas labels does not match averages.")
logger.error("Check " + str(self.options.atlas_lib) + " and try again.")
if (not len(average) == len(labels)) or (not len(average) == len(masks)):
print "\nError: not all atlases/labels/masks match."
print "The allowed naming conventions are:\n{atlas}.mnc\n{atlas}_labels.mnc\n{atlas}_mask.mnc"
print "\nand:\n{atlas}_average.mnc\n{atlas}_labels.mnc\n{atlas}_mask.mnc\n"
print "Check the atlas library directory: " + str(self.options.atlas_lib) + " and try again."
print "Exiting..."
sys.exit()
elif not len(average) == len(masks):
logger.error("Number of input atlas masks does not match averages.")
logger.error("Check " + str(self.options.atlas_lib) + " and try again.")
sys.exit()
else:
# match labels with averages
numLibraryAtlases = len(labels)
Expand All @@ -98,7 +103,13 @@ def run(self):
break
atlasPipeFH.addLabels(abspath(iLabel), inputLabel=True)
atlases.append(atlasPipeFH)


# exit if no atlases were found in the specified directory
if numLibraryAtlases == 0:
print "\nError: no atlases were found in the specified directory: %s" % self.options.atlas_lib
print "Exiting..."
sys.exit()

#MF TODO: add some checking to make sure that atlas/labels/naming all worked correctly
# eg if we have A4_mask.mnc "matching" with A3_labels, we wont get right thing.

Expand Down
73 changes: 0 additions & 73 deletions applications/cortical_thickness.py

This file was deleted.

13 changes: 11 additions & 2 deletions atoms_and_modules/LSQ6.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def addLSQ6ArgumentGroup(parser):
group.add_argument("--lsq6-simple", dest="lsq6_method",
action="store_const", const="lsq6_simple",
help="Run a 6 parameter alignment assuming that the input files are roughly "
"aligned: same space, similar orientation. [Default = %(default)s]")
"aligned: same space, similar orientation. Keep in mind that if you use an "
"initial model with both a standard and a native space, the assumption is "
"that the input files are already roughly aligned to the native space [Default = %(default)s]")
group.add_argument("--lsq6-centre-estimation", dest="lsq6_method",
action="store_const", const="lsq6_centre_estimation",
help="Run a 6 parameter alignment assuming that the input files have a "
Expand Down Expand Up @@ -313,9 +315,16 @@ def setupPipeline(self):
self.p.addPipeline(nucorrection.p)

if self.options.inormalize:
need_to_resample_to_LSQ6 = True;
# Currently when no non-uniformity correction is applied, the input
# file is intensity normalized in lsq6 space, not native space. This
# means that in that case, we do not need to resample to LSQ6 anymore
# since the file is already in that space:
if not self.options.nuc:
need_to_resample_to_LSQ6 = False
intensity_normalization = IntensityNormalization(self.inputFiles,
initial_model=self.initModel,
resampleINORMtoLSQ6=True,
resampleINORMtoLSQ6=need_to_resample_to_LSQ6,
targetForLSQ6=self.target)
self.p.addPipeline(intensity_normalization.p)

Expand Down
8 changes: 6 additions & 2 deletions atoms_and_modules/MAGeT_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ def addMAGeTArgumentGroup(parser):
group.add_argument("--atlas-library", dest="atlas_lib",
type=str, default="atlas_label_pairs",
help="Directory of existing atlas/label pairs")
group.add_argument("--pairwise", dest="pairwise",
action="store_true",
help="""If specified, register inputs to each other pairwise. [Default]""")
group.add_argument("--no-pairwise", dest="pairwise",
action="store_false", default=True,
help="""Pairwise crossing of templates. [Default = %(default)s]. If specified, only register inputs to atlases in library""")
action="store_false",
help="""If specified, only register inputs to atlases in library.""")
parser.set_defaults(pairwise=True)
group.add_argument("--mask", dest="mask",
action="store_true", default=False,
help="Create a mask for all images prior to handling labels. [Default = %(default)s]")
Expand Down
73 changes: 0 additions & 73 deletions atoms_and_modules/laplacian_atoms.py

This file was deleted.

42 changes: 18 additions & 24 deletions atoms_and_modules/minc_atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def __init__(self,
if self.useMask:
self.target_mask = target_mask
except:
print "Failed in putting together mincANTS command."
print "Unexpected error: ", sys.exc_info()
print "Failed in putting together mincANTS command; unexpected error: "
raise

self.similarity_metric = similarity_metric
self.weight = weight
Expand Down Expand Up @@ -218,8 +218,8 @@ def __init__(self,
self.source_mask = source_mask
self.target_mask = target_mask
except:
print "Failed in putting together minctracc command."
print "Unexpected error: ", sys.exc_info()
print "Failed in putting together minctracc command; unexpected error: "
raise

self.linearparam = linearparam
self.iterations = str(iterations)
Expand Down Expand Up @@ -354,8 +354,8 @@ def __init__(self,
gradientBase = blurBase.replace("blur", "dxyz")
self.outputFiles += ["".join([gradientBase, ".mnc"])]
except:
print "Failed in putting together blur command."
print "Unexpected error: ", sys.exc_info()
print "Failed in putting together blur command; unexpected error: "
raise

self.cmd = ["mincblur", "-clobber", "-no_apodize", "-fwhm", str(fwhm),
self.inputFiles[0], self.base]
Expand All @@ -371,8 +371,7 @@ def __init__(self,
# characters. Given that we don't know which version of mincblur is installed
# (this should and will be fixed at some point in the future), we'll exit here
if len(self.outputFiles[0]) > 264:
print "\n\nError: mincblur (potentially) has a hardcoded limit for the allowed length of the output file. The following command will not be able to run: \n\n%s\n\nPlease rename your input files/paths to make sure the filenames become shorter.\n" % self.cmd
sys.exit()
raise Exception("mincblur (potentially) has a hardcoded limit for the allowed length of the output file. The following command will not be able to run: \n\n%s\n\nPlease rename your input files/paths to make sure the filenames become shorter.\n" % self.cmd)

class autocrop(CmdStage):
def __init__(self,
Expand Down Expand Up @@ -407,7 +406,7 @@ def __init__(self,

except:
print "Failed in putting together autocrop command"
print "Unexpected error: ", sys.exc_info()
raise

self.addDefaults()
self.finalizeCommand()
Expand Down Expand Up @@ -528,11 +527,8 @@ def __init__(self,
argarray could contain inFile and/or output files
"""

argArray = kwargs.pop("argArray", None)
if not argArray:
CmdStage.__init__(self, ["mincresample"])
else:
CmdStage.__init__(self, ["mincresample"] + argArray)
argArray = kwargs.pop("argArray", [])
CmdStage.__init__(self, ["mincresample"] + argArray)

try:
#MF TODO: What if we don't want to use lastBasevol?
Expand Down Expand Up @@ -592,8 +588,8 @@ def __init__(self,
self.logFile = logFile

except:
print "Failed in putting together resample command"
print "Unexpected error: ", sys.exc_info()
print "Failed in putting together resample command; unexpected error: "
raise

self.addDefaults()
self.finalizeCommand()
Expand Down Expand Up @@ -756,8 +752,8 @@ def __init__(self,
self.logFile = logFile

except:
print "Failed in putting together mincaverage command"
print "Unexpected error: ", sys.exc_info()
print "Failed in putting together mincaverage command; unexpected error: "
raise

self.addDefaults()
self.finalizeCommand()
Expand Down Expand Up @@ -864,8 +860,7 @@ def __init__(self,
self.source = inSource
self.target = inTarget
except:
print "Failed in putting together RotationalMinctracc command."
print "Unexpected error: ", sys.exc_info()
print "Failed in putting together RotationalMinctracc command; unexpected error:"
raise

# The resolution is used to determine the step size and
Expand Down Expand Up @@ -929,8 +924,7 @@ def finalizeCommand(self,
self.cmd += ["-m", mask]
self.inputFiles.append(mask)
except:
print "Failed retrieving information about a mask for the target in RotationalMinctracc."
print "Unexpected error: ", sys.exc_info()
print "Failed retrieving information about a mask for the target in RotationalMinctracc; unexpected error: "
raise


Expand Down Expand Up @@ -998,8 +992,8 @@ def __init__(self,
self.logFile = logFile

except:
print "Failed in putting together xfminvert command"
print "Unexpected error: ", sys.exc_info()
print "Failed in putting together xfminvert command; unexpected error: "
raise

self.finalizeCommand()
self.setName()
Expand Down
Loading

0 comments on commit 2c090e1

Please sign in to comment.