Skip to content
Snippets Groups Projects
Commit 4fb33a00 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Melodic analysis is detected if either melodic_IC or melodic_oIC are present

parent 13d87165
No related branches found
No related tags found
No related merge requests found
...@@ -48,14 +48,18 @@ def isMelodicImage(path): ...@@ -48,14 +48,18 @@ def isMelodicImage(path):
try: try:
path = fslimage.addExt(path, mustExist=True) path = fslimage.addExt(path)
except fslimage.PathError: except fslimage.PathError:
return False return False
dirname = op.dirname( path) dirname = op.dirname( path)
filename = op.basename(path) filename = op.basename(path)
filename = fslimage.removeExt(filename)
return filename.startswith('melodic_IC') and isMelodicDir(dirname) prefixes = ['melodic_IC',
'melodic_oIC']
return any([filename == p for p in prefixes]) and isMelodicDir(dirname)
def isMelodicDir(path): def isMelodicDir(path):
...@@ -63,7 +67,8 @@ def isMelodicDir(path): ...@@ -63,7 +67,8 @@ def isMelodicDir(path):
a MELODIC directory, ``False`` otherwise. A melodic directory: a MELODIC directory, ``False`` otherwise. A melodic directory:
- Must be named ``*.ica``. - Must be named ``*.ica``.
- Must contain a file called ``melodic_IC.nii.gz``. - Must contain a file called ``melodic_IC.nii.gz`` or
``melodic_oIC.nii.gz``.
- Must contain a file called ``melodic_mix``. - Must contain a file called ``melodic_mix``.
- Must contain a file called ``melodic_FTmix``. - Must contain a file called ``melodic_FTmix``.
""" """
...@@ -78,10 +83,16 @@ def isMelodicDir(path): ...@@ -78,10 +83,16 @@ def isMelodicDir(path):
if not any([dirname.endswith(suf) for suf in sufs]): if not any([dirname.endswith(suf) for suf in sufs]):
return False return False
# Must contain an image file called melodic_IC # Must contain an image file called
try: # melodic_IC or melodic_oIC
fslimage.addExt(op.join(dirname, 'melodic_IC'), mustExist=True) prefixes = ['melodic_IC', 'melodic_oIC']
except fslimage.PathError: for p in prefixes:
try:
fslimage.addExt(op.join(dirname, p))
break
except fslimage.PathError:
pass
else:
return False return False
# Must contain files called # Must contain files called
...@@ -128,7 +139,7 @@ def getDataFile(meldir): ...@@ -128,7 +139,7 @@ def getDataFile(meldir):
dataFile = op.join(topDir, 'filtered_func_data') dataFile = op.join(topDir, 'filtered_func_data')
try: return fslimage.addExt(dataFile, mustExist=True) try: return fslimage.addExt(dataFile)
except fslimage.PathError: return None except fslimage.PathError: return None
...@@ -139,7 +150,10 @@ def getMeanFile(meldir): ...@@ -139,7 +150,10 @@ def getMeanFile(meldir):
def getICFile(meldir): def getICFile(meldir):
"""Returns the path to the melodic IC image. """ """Returns the path to the melodic IC image. """
return fslimage.addExt(op.join(meldir, 'melodic_IC')) try:
return fslimage.addExt(op.join(meldir, 'melodic_IC'))
except fslimage.PathError:
return fslimage.addExt(op.join(meldir, 'melodic_oIC'))
def getMixFile(meldir): def getMixFile(meldir):
......
...@@ -55,7 +55,7 @@ class MelodicImage(fslimage.Image): ...@@ -55,7 +55,7 @@ class MelodicImage(fslimage.Image):
""" """
if op.isdir(path): if op.isdir(path):
path = op.join(path, 'melodic_IC') path = melanalysis.getICFile(path)
if not melanalysis.isMelodicImage(path): if not melanalysis.isMelodicImage(path):
raise ValueError('{} does not appear to be a ' raise ValueError('{} does not appear to be a '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment