Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
0e98316b
Commit
0e98316b
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: isMelodicDir no longer requires dir to end in .ica, and no longer accepts
a file or sub-dir
parent
34084a75
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/melodicanalysis.py
+12
-16
12 additions, 16 deletions
fsl/data/melodicanalysis.py
with
12 additions
and
16 deletions
fsl/data/melodicanalysis.py
+
12
−
16
View file @
0e98316b
...
...
@@ -33,7 +33,6 @@ import logging
import
os.path
as
op
import
numpy
as
np
import
fsl.utils.path
as
fslpath
import
fsl.data.image
as
fslimage
import
fsl.data.featanalysis
as
featanalysis
...
...
@@ -63,10 +62,9 @@ def isMelodicImage(path):
def
isMelodicDir
(
path
):
"""
Returns ``True`` if the given path looks like it is
contained within
a MELODIC directory,
``False`` otherwise. A
melodic
directory:
"""
Returns ``True`` if the given path looks like it is
a MELODIC directory,
``False`` otherwise. A
MELODIC
directory:
- Must be named ``*.ica``.
- Must contain a file called ``melodic_IC.nii.gz`` or
``melodic_oIC.nii.gz``.
- Must contain a file called ``melodic_mix``.
...
...
@@ -75,12 +73,7 @@ def isMelodicDir(path):
path
=
op
.
abspath
(
path
)
if
op
.
isdir
(
path
):
dirname
=
path
else
:
dirname
=
op
.
dirname
(
path
)
sufs
=
[
'
.ica
'
]
if
not
any
([
dirname
.
endswith
(
suf
)
for
suf
in
sufs
]):
if
not
op
.
isdir
(
path
):
return
False
# Must contain an image file called
...
...
@@ -88,7 +81,7 @@ def isMelodicDir(path):
prefixes
=
[
'
melodic_IC
'
,
'
melodic_oIC
'
]
for
p
in
prefixes
:
try
:
fslimage
.
addExt
(
op
.
join
(
dirname
,
p
))
fslimage
.
addExt
(
op
.
join
(
path
,
p
))
break
except
fslimage
.
PathError
:
pass
...
...
@@ -97,8 +90,8 @@ def isMelodicDir(path):
# Must contain files called
# melodic_mix and melodic_FTmix
if
not
op
.
exists
(
op
.
join
(
dirname
,
'
melodic_mix
'
)):
return
False
if
not
op
.
exists
(
op
.
join
(
dirname
,
'
melodic_FTmix
'
)):
return
False
if
not
op
.
exists
(
op
.
join
(
path
,
'
melodic_mix
'
)):
return
False
if
not
op
.
exists
(
op
.
join
(
path
,
'
melodic_FTmix
'
)):
return
False
return
True
...
...
@@ -108,10 +101,13 @@ def getAnalysisDir(path):
to that MELODIC directory is returned. Otherwise, ``None`` is returned.
"""
meldir
=
fslpath
.
deepest
(
path
,
[
'
.ica
'
])
if
not
op
.
isdir
(
path
):
path
=
op
.
dirname
(
path
)
if
meldir
is
not
None
and
isMelodicDir
(
meldir
):
return
meldir
while
path
not
in
(
op
.
sep
,
''
):
if
isMelodicDir
(
path
):
return
path
path
=
op
.
dirname
(
path
)
return
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment