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
8be19316
Commit
8be19316
authored
5 months ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
MNT: Modify saveLabelFile to support saving classification probabilities
parent
d45b3ce9
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/fixlabels.py
+24
-15
24 additions, 15 deletions
fsl/data/fixlabels.py
with
24 additions
and
15 deletions
fsl/data/fixlabels.py
+
24
−
15
View file @
8be19316
...
...
@@ -343,33 +343,40 @@ def saveLabelFile(allLabels,
filename
,
dirname
=
None
,
listBad
=
True
,
signalLabels
=
None
):
signalLabels
=
None
,
probabilities
=
None
):
"""
Saves the given classification labels to the specified file. The
classifications are saved in the format described in the
:func:`loadLabelFile` method.
:arg allLabels: A list of lists, one list for each component, where
each list contains the labels for the corresponding
component.
:arg allLabels:
A list of lists, one list for each component, where
each list contains the labels for the corresponding
component.
:arg filename: Name of the file to which the labels should be saved.
:arg filename:
Name of the file to which the labels should be saved.
:arg dirname: If provided, is output as the first line of the file.
Intended to be a relative path to the MELODIC analysis
directory with which this label file is associated. If
not provided, a ``
'
.
'
`` is output as the first line.
:arg dirname:
If provided, is output as the first line of the file.
Intended to be a relative path to the MELODIC analysis
directory with which this label file is associated. If
not provided, a ``
'
.
'
`` is output as the first line.
:arg listBad: If ``True`` (the default), the last line of the file
will contain a comma separated list of components which
are deemed
'
noisy
'
(see :func:`isNoisyComponent`).
:arg listBad:
If ``True`` (the default), the last line of the file
will contain a comma separated list of components which
are deemed
'
noisy
'
(see :func:`isNoisyComponent`).
:arg signalLabels: Labels which should be deemed
'
signal
'
- see the
:func:`isNoisyComponent` function.
:arg signalLabels: Labels which should be deemed
'
signal
'
- see the
:func:`isNoisyComponent` function.
:arg probabilities: Classification probabilities. If provided, the
probability for each component is saved to the file.
"""
lines
=
[]
noisyComps
=
[]
if
probabilities
is
not
None
and
len
(
probabilities
)
!=
len
(
allLabels
):
raise
ValueError
(
'
len(probabilities) != len(allLabels)
'
)
# The first line - the melodic directory name
if
dirname
is
None
:
dirname
=
'
.
'
...
...
@@ -387,6 +394,9 @@ def saveLabelFile(allLabels,
labels
=
[
l
.
replace
(
'
,
'
,
'
_
'
)
for
l
in
labels
]
tokens
=
[
str
(
comp
)]
+
labels
+
[
str
(
noise
)]
if
probabilities
is
not
None
:
tokens
.
append
(
f
'
{
probabilities
[
i
]
:
0.6
f
}
'
)
lines
.
append
(
'
,
'
.
join
(
tokens
))
if
noise
:
...
...
@@ -422,4 +432,3 @@ class InvalidLabelFileError(Exception):
"""
Exception raised by the :func:`loadLabelFile` function when an attempt
is made to load an invalid label file.
"""
pass
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