Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
abbad5a0
Commit
abbad5a0
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: fixlabels.loadLabelFile can now return list of noise components specified
in file.
parent
ac3fd5c1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/fixlabels.py
+31
-21
31 additions, 21 deletions
fsl/data/fixlabels.py
with
31 additions
and
21 deletions
fsl/data/fixlabels.py
+
31
−
21
View file @
abbad5a0
...
...
@@ -19,7 +19,10 @@
import
os.path
as
op
def
loadLabelFile
(
filename
,
includeLabel
=
None
,
excludeLabel
=
None
):
def
loadLabelFile
(
filename
,
includeLabel
=
None
,
excludeLabel
=
None
,
returnIndices
=
False
):
"""
Loads component labels from the specified file. The file is assuemd
to be of the format generated by FIX, Melview or ICA-AROMA; such a file
should have a structure resembling the following::
...
...
@@ -70,23 +73,30 @@ def loadLabelFile(filename, includeLabel=None, excludeLabel=None):
*bad* components, i.e. those components which are not classified as
signal or unknown.
:arg filename: Name of the label file to load.
:arg includeLabel: If the file contains a single line containing a list
component indices, this label will be used for the
components in the list. Defaults to
'
Unclassified
noise
'
for FIX-like files, and
'
Movement
'
for
ICA-AROMA-like files.
:arg excludeLabel: If the file contains a single line containing component
indices, this label will be used for the components
that are not in the list. Defaults to
'
Signal
'
for
FIX-like files, and
'
Unknown
'
for ICA-AROMA-like files.
:returns: A tuple containing the path to the melodic directory
as specified in the label file, and a list of lists, one
list per component, with each list containing the labels for
the corresponding component.
:arg filename: Name of the label file to load.
:arg includeLabel: If the file contains a single line containing a list
component indices, this label will be used for the
components in the list. Defaults to
'
Unclassified
noise
'
for FIX-like files, and
'
Movement
'
for
ICA-AROMA-like files.
:arg excludeLabel: If the file contains a single line containing component
indices, this label will be used for the components
that are not in the list. Defaults to
'
Signal
'
for
FIX-like files, and
'
Unknown
'
for ICA-AROMA-like files.
:arg returnIndices: Defaults to ``False``. If ``True``, a list containing
the noisy component numbers that were listed in the
file is returned.
:returns: A tuple containing:
- The path to the melodic directory as specified in the label
file
- A list of lists, one list per component, with each list
containing the labels for the corresponding component.
- If ``returnIndices is True``, a list of the noisy component
indices (starting from 1) that were specified in the file.
"""
signalLabels
=
None
...
...
@@ -176,7 +186,7 @@ def loadLabelFile(filename, includeLabel=None, excludeLabel=None):
try
:
compIdx
=
int
(
tokens
[
0
])
except
:
except
ValueError
:
raise
InvalidLabelFileError
(
'
Invalid FIX classification file -
'
'
line {}: {}
'
.
format
(
i
+
1
,
compLine
))
...
...
@@ -203,7 +213,6 @@ def loadLabelFile(filename, includeLabel=None, excludeLabel=None):
noise
=
isNoisyComponent
(
labels
,
signalLabels
)
if
noise
and
(
comp
not
in
noisyComps
):
print
(
signalLabels
)
raise
InvalidLabelFileError
(
'
Noisy component {} has invalid
'
'
labels: {}
'
.
format
(
comp
,
labels
))
...
...
@@ -217,7 +226,8 @@ def loadLabelFile(filename, includeLabel=None, excludeLabel=None):
raise
InvalidLabelFileError
(
'
Noisy component {} is missing
'
'
a noise label
'
.
format
(
comp
))
return
melDir
,
allLabels
if
returnIndices
:
return
melDir
,
allLabels
,
noisyComps
else
:
return
melDir
,
allLabels
def
saveLabelFile
(
allLabels
,
...
...
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