Skip to content

Commit

Permalink
Merge branch 'release-1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
mcvaneede committed Sep 26, 2014
2 parents ecd7810 + c39f9ea commit 75fb82f
Show file tree
Hide file tree
Showing 23 changed files with 1,021 additions and 349 deletions.
6 changes: 3 additions & 3 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Run: python setup.py install

Dependencies:

Pyro - http://irmen.home.xs4all.nl/pyro/
Pyro4 - http://pythonhosted.org/Pyro4
NetworkX - http://networkx.lanl.gov/
Py.test - http://pytest.org/

In Ubuntu (tested on 10.04), run:
In Ubuntu (tested on 12.04), run:
apt-get install python-networkx
pip install pyro
pip install pytest
pip install pytest
17 changes: 17 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
New in Version 1.7
==================
* the communication between the server and the executors has been upgraded
from Pyro3 to Pyro4. Currently the following environment variables should
be set:

PYRO_DETAILED_TRACEBACK=True
PYRO_COMMTIMEOUT=2
PYRO_SERVERTYPE=multiplex
PYRO_LOGLEVEL=DEBUG

* the stiffness, weight and similarity parameters for minctracc can now be
set through the non linear protocol in MBM.py
* all output from the server/executors will be stored in the current
working directory


New in Version 1.6
====================
* fix to MAGeT.py. Solves issues with the voxel_vote command.
Expand Down
123 changes: 123 additions & 0 deletions applications/#MBM.py#
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env python

from pydpiper.application import AbstractApplication
import atoms_and_modules.registration_functions as rf
import atoms_and_modules.registration_file_handling as rfh
import atoms_and_modules.LSQ6 as lsq6
import atoms_and_modules.LSQ12 as lsq12
import atoms_and_modules.NLIN as nlin
import atoms_and_modules.minc_parameters as mp
import atoms_and_modules.stats_tools as st
import Pyro
import os
from optparse import OptionGroup
import logging


logger = logging.getLogger(__name__)

Pyro.config.PYRO_MOBILE_CODE=1

def addMBMGroup(parser):
group = OptionGroup(parser, "MBM options",
"Options for MICe-build-model.")
parser.add_option_group(group)

class MBMApplication(AbstractApplication):
def setup_options(self):
"""Add option groups from specific modules"""
addMBMGroup(self.parser)
rf.addGenRegOptionGroup(self.parser)
lsq6.addLSQ6OptionGroup(self.parser)
lsq12.addLSQ12OptionGroup(self.parser)
nlin.addNlinRegOptionGroup(self.parser)
st.addStatsOptions(self.parser)

self.parser.set_usage("%prog [options] input files")

def setup_appName(self):
appName = "MICe-build-model"
return appName

def run(self):
options = self.options
args = self.args

# Setup output directories for different registration modules.
dirs = rf.setupDirectories(self.outputDir, options.pipeline_name, module="ALL")
inputFiles = rf.initializeInputFiles(args, dirs.processedDir, maskDir=options.mask_dir)

#Setup init model and inital target. Function also exists if no target was specified.
initModel, targetPipeFH = rf.setInitialTarget(options.init_model,
options.lsq6_target,
dirs.lsq6Dir,
self.outputDir)

#LSQ6 MODULE, NUC and INORM
runLSQ6NucInorm = lsq6.LSQ6NUCInorm(inputFiles,
targetPipeFH,
initModel,
dirs.lsq6Dir,
options)
self.pipeline.addPipeline(runLSQ6NucInorm.p)

# LSQ12 MODULE
# We need to specify a likeFile/space when all files are resampled
# at the end of LSQ12. If one is not specified, use standard space.
if options.lsq12_likeFile == None:
targetPipeFH = initModel[0]
else:
targetPipeFH = rfh.RegistrationFHBase(os.path.abspath(options.lsq12_likeFile),
basedir=dirs.lsq12Dir)
lsq12module = lsq12.FullLSQ12(inputFiles,
dirs.lsq12Dir,
likeFile=targetPipeFH,
maxPairs=None,
lsq12_protocol=options.lsq12_protocol,
subject_matter=options.lsq12_subject_matter)
lsq12module.iterate()
self.pipeline.addPipeline(lsq12module.p)

#TODO: Additional NUC step here. This will impact both the lsq6 and lsq12 modules.
# May want to not do resampling and averaging by default. TBD.

#Target mask for registration--I HATE this hack, as is noted in check-in and
#as a github issue.
if lsq12module.lsq12AvgFH.getMask()== None:
if initModel[0]:
lsq12module.lsq12AvgFH.setMask(initModel[0].getMask())

#NLIN MODULE - Register with minctracc or mincANTS based on options.reg_method
nlinObj = nlin.initializeAndRunNLIN(dirs.lsq12Dir,
inputFiles,
dirs.nlinDir,
avgPrefix=options.pipeline_name,
createAvg=False,
targetAvg=lsq12module.lsq12AvgFH,
nlin_protocol=options.nlin_protocol,
reg_method=options.reg_method)

self.pipeline.addPipeline(nlinObj.p)
self.nlinAverages = nlinObj.nlinAverages

#STATS MODULE
if options.calc_stats:
#Choose final average from array of nlin averages
finalNlin = self.nlinAverages[-1]
# For each input file, calculate statistics from final average (finalNlin)
# to the inputFH space where all linear differences have been accounted for (LSQ12).
# The additionalXfm specified for each inputFH is the transform from the lsq6 to lsq12
# space for that scan. This encapsulates linear differences and is necessary for
# some of the calculations in CalcStats.
for inputFH in inputFiles:
stats = st.CalcStats(inputFH,
finalNlin,
options.stats_kernels,
additionalXfm=lsq12module.lsq12AvgXfms[inputFH])
self.pipeline.addPipeline(stats.p)

if __name__ == "__main__":

application = MBMApplication()
application.start()

3 changes: 0 additions & 3 deletions applications/MAGeT.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from atoms_and_modules.MAGeT_modules import MAGeTMask, MAGeTRegister, voxelVote, addMAGeTOptionGroup
from atoms_and_modules.LSQ12 import addLSQ12OptionGroup
from atoms_and_modules.NLIN import addNlinRegOptionGroup
import Pyro
from os.path import abspath, join
import logging
import glob
Expand All @@ -16,8 +15,6 @@

logger = logging.getLogger(__name__)

Pyro.config.PYRO_MOBILE_CODE=1

class MAGeTApplication(AbstractApplication):
def setup_options(self):
addGenRegOptionGroup(self.parser)
Expand Down
5 changes: 1 addition & 4 deletions applications/MBM.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
import atoms_and_modules.NLIN as nlin
import atoms_and_modules.minc_parameters as mp
import atoms_and_modules.stats_tools as st
import Pyro
import os
from optparse import OptionGroup
import logging


logger = logging.getLogger(__name__)

Pyro.config.PYRO_MOBILE_CODE=1

def addMBMGroup(parser):
group = OptionGroup(parser, "MBM options",
"Options for MICe-build-model.")
Expand Down Expand Up @@ -120,4 +117,4 @@ def run(self):

application = MBMApplication()
application.start()


3 changes: 0 additions & 3 deletions applications/pairwise_nlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import atoms_and_modules.minc_atoms as ma
import atoms_and_modules.stats_tools as st
import atoms_and_modules.option_groups as og
import Pyro
from optparse import OptionGroup
from datetime import date
from os.path import abspath, isdir
Expand All @@ -17,8 +16,6 @@

logger = logging.getLogger(__name__)

Pyro.config.PYRO_MOBILE_CODE=1

"""NOTE: This application needs a significant overhaul and/or combining with the RegistrationChain
Application. Until this comment is removed, please consider this class DEPRECATED."""

Expand Down
3 changes: 0 additions & 3 deletions applications/registration_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@
import atoms_and_modules.NLIN as nlin
import atoms_and_modules.stats_tools as st
import atoms_and_modules.minc_parameters as mp
import Pyro
from optparse import OptionGroup
from os.path import abspath, isdir, isfile
import logging
import sys

logger = logging.getLogger(__name__)

Pyro.config.PYRO_MOBILE_CODE=1

def addRegChainOptionGroup(parser):
"""option group for the command line argument parser"""
group = OptionGroup(parser, "Registration-chain options",
Expand Down
3 changes: 0 additions & 3 deletions applications/twolevel_model_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
import atoms_and_modules.NLIN as nl
import atoms_and_modules.stats_tools as st
import atoms_and_modules.registration_file_handling as rfh
import Pyro
from os.path import split, splitext, abspath
import sys
import logging

logger = logging.getLogger(__name__)

Pyro.config.PYRO_MOBILE_CODE=1

class LongitudinalTwolevelNlin(AbstractApplication):
def setup_options(self):
helpString="""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
"gradient";TRUE;TRUE;TRUE;TRUE;TRUE;TRUE
"w_translations";0.4;0.4;0.4;0.4;0.4;0.4
"optimization";"-use_simplex";"-use_simplex";"-use_simplex";"-use_simplex";"-use_simplex";"-use_simplex"
"stiffness";0.5;0.5;0.5;0.5;0.5;0.5
"weight";0.3;0.3;0.3;0.3;0.3;0.3
"similarity";0.5;0.5;0.5;0.5;0.5;0.5
Loading

0 comments on commit 75fb82f

Please sign in to comment.