Skip to content

Commit

Permalink
STYLE: Do PEP8 compliance
Browse files Browse the repository at this point in the history
To become pep8 compliant, the autopep8 tool
was used: http://pypi.python.org/pypi/autopep8/0.8.1

Since the code is really hard to read at the default
79 characters per line, I've optted to allow lines
upto 300 characters long.

for i in *.py; do
   autopep8 --max-line-length=300 -i $i;
done
  • Loading branch information
hjmjohnson committed Jan 6, 2013
1 parent effa565 commit f902579
Show file tree
Hide file tree
Showing 24 changed files with 2,362 additions and 2,279 deletions.
298 changes: 153 additions & 145 deletions AutoWorkup/BAWantsRegistrationBuildTemplate.py

Large diffs are not rendered by default.

37 changes: 20 additions & 17 deletions AutoWorkup/BRAINSABCext.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from nipype.interfaces.base import CommandLine, CommandLineInputSpec, TraitedSpec, File, Directory, traits, isdefined, InputMultiPath, OutputMultiPath
import os
from SEMTools.segmentation.specialized import BRAINSABCOutputSpec, BRAINSABCInputSpec, BRAINSABC
#from SEMTools import BRAINSABCInputSpec,BRAINSABCOutputSpec,BRAINSABC
from SEMTools.segmentation.specialized import BRAINSABCOutputSpec, BRAINSABCInputSpec, BRAINSABC
# from SEMTools import BRAINSABCInputSpec,BRAINSABCOutputSpec,BRAINSABC

from xml.etree import ElementTree as et


class GetPosteriorsFromAtlasXML():

def __init__(self, xmlFile):
Expand Down Expand Up @@ -36,7 +38,7 @@ def getPosteriorFileNameList(self, posteriorTemplate):
for priorType in self.priorTypeNameList:
posteriorFileNameList.append("POSTERIOR_{priorT}.nii.gz".format(priorT=priorType))
## HACK: The following is correct from the command line posteriorTemplate arguments
#posteriorFileNameList.append(posteriorTemplate % priorType)
# posteriorFileNameList.append(posteriorTemplate % priorType)
return posteriorFileNameList

"""
Expand All @@ -45,17 +47,19 @@ class BRAINSABCextInputSpec(BRAINSABCInputSpec):
posteriorImages = traits.Either(traits.Bool(True,desc="The automatically generated posterior images"), InputMultiPath(File(),), hash_files = False,argstr = "")
"""


class BRAINSABCextOutputSpec(BRAINSABCOutputSpec):
# Not convenient outputAverageImages = OutputMultiPath(File(exists=True), exists = True)
outputT1AverageImage = traits.Either( File(exists=True), None )
outputT2AverageImage = traits.Either( File(exists=True), None )
outputPDAverageImage = traits.Either( File(exists=True), None )
outputFLAverageImage = traits.Either( File(exists=True), None )
outputT1AverageImage = traits.Either(File(exists=True), None)
outputT2AverageImage = traits.Either(File(exists=True), None)
outputPDAverageImage = traits.Either(File(exists=True), None)
outputFLAverageImage = traits.Either(File(exists=True), None)
posteriorImages = OutputMultiPath(File(exists=True), exists=True)
atlasToSubjectInverseTransform = traits.Either( File(exists=True), None )
atlasToSubjectInverseTransform = traits.Either(File(exists=True), None)


class BRAINSABCext(BRAINSABC):
#input_spec= BRAINSABCextInputSpec
# input_spec= BRAINSABCextInputSpec
output_spec = BRAINSABCextOutputSpec

def _list_outputs(self):
Expand All @@ -65,17 +69,17 @@ def _list_outputs(self):
'outputPDAverageImage',
'outputFLAverageImage',
'atlasToSubjectInverseTransform'
]
]
full_outputs = self.output_spec().get()
pruned_outputs = dict()
for key, value in full_outputs.iteritems():
if key not in custom_implied_outputs_with_no_inputs:
pruned_outputs[key] = value
outputs = super(BRAINSABCext,self)._outputs_from_inputs( pruned_outputs )
input_check = {'T1':('outputT1AverageImage', 't1_average_BRAINSABC.nii.gz'),
'T2':('outputT2AverageImage', 't2_average_BRAINSABC.nii.gz'),
'PD':('outputPDAverageImage', 'pd_average_BRAINSABC.nii.gz'),
'FL':('outputFLAverageImage', 'fl_average_BRAINSABC.nii.gz')}
outputs = super(BRAINSABCext, self)._outputs_from_inputs(pruned_outputs)
input_check = {'T1': ('outputT1AverageImage', 't1_average_BRAINSABC.nii.gz'),
'T2': ('outputT2AverageImage', 't2_average_BRAINSABC.nii.gz'),
'PD': ('outputPDAverageImage', 'pd_average_BRAINSABC.nii.gz'),
'FL': ('outputFLAverageImage', 'fl_average_BRAINSABC.nii.gz')}
for key, values in input_check.iteritems():
if key in self.inputs.inputVolumeTypes:
outputs[values[0]] = os.path.abspath(values[1])
Expand All @@ -86,10 +90,9 @@ def _list_outputs(self):
PosteriorPaths = PosteriorOutputs.getPosteriorFileNameList(self.inputs.posteriorTemplate)
outputs['posteriorImages'] = [os.path.abspath(postPath) for postPath in PosteriorPaths]

fixed_inverse_name=os.path.abspath(outputs['atlasToSubjectTransform'].replace(".h5","_Inverse.h5"))
fixed_inverse_name = os.path.abspath(outputs['atlasToSubjectTransform'].replace(".h5", "_Inverse.h5"))
if os.path.exists(fixed_inverse_name):
outputs['atlasToSubjectInverseTransform'] = fixed_inverse_name
else:
outputs['atlasToSubjectInverseTransform'] = None
return outputs

Loading

0 comments on commit f902579

Please sign in to comment.