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
998f3d77
Commit
998f3d77
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: Drop bad component indices
parent
7f827603
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/scripts/extract_noise.py
+32
-6
32 additions, 6 deletions
fsl/scripts/extract_noise.py
with
32 additions
and
6 deletions
fsl/scripts/extract_noise.py
+
32
−
6
View file @
998f3d77
...
...
@@ -5,7 +5,8 @@
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""
"""
This module defines the ``extract_noise`` script, for extracting component
time series from a MELODIC ``.ica`` directory.
"""
...
...
@@ -129,11 +130,21 @@ def parseArgs(args):
return
args
def
genComponentIndexList
(
comps
):
"""
def
genComponentIndexList
(
comps
,
ncomps
):
"""
Turns the given sequence of integers and file paths into a list
of 0-based component indices.
:arg comps: Sequence containing 1-based component indices, and/or paths
to FIX/AROMA label text files.
:arg ncomps: Number of components in the input data - indices larger than
this will be ignored.
:returns: List of 0-based component indices.
"""
allcomps
=
[]
badcomps
=
[]
for
c
in
comps
:
if
isinstance
(
c
,
int
):
...
...
@@ -141,13 +152,27 @@ def genComponentIndexList(comps):
else
:
ccomps
=
fixlabels
.
loadLabelFile
(
c
,
returnIndices
=
True
)[
2
]
allcomps
.
extend
([
cc
-
1
for
cc
in
ccomps
])
badcomps
.
extend
([
cc
for
cc
in
ccomps
if
cc
>=
ncomps
])
allcomps
.
extend
([
cc
-
1
for
cc
in
ccomps
if
cc
<
ncomps
])
if
len
(
badcomps
)
>
0
:
print
(
'
Warning: Ignoring components: {}
'
.
format
(
badcomps
),
file
=
sys
.
stderr
)
return
list
(
sorted
(
set
(
allcomps
)))
def
loadConfoundFiles
(
conffiles
,
npts
):
"""
"""
Loads the given confound files, and copies them all into a single 2D
``(npoints, nconfounds)`` matrix.
:arg conffiles: Sequence of paths to files containing confound time series
(where each row corresponds to a time point, and each
column corresponds to a single confound).
:arg npts: Expected number of time points
:returns: A ``(npoints, nconfounds)`` ``numpy`` matrix.
"""
matrices
=
[]
...
...
@@ -162,7 +187,8 @@ def loadConfoundFiles(conffiles, npts):
if
mat
.
shape
[
0
]
!=
npts
:
print
(
'
Warning: confound file {} does not have correct number of
'
'
points (expected {}, has {}). Output will be truncated or
'
'
padded with NaNs.
'
.
format
(
cfile
,
npts
,
mat
.
shape
[
1
]))
'
padded with NaNs.
'
.
format
(
cfile
,
npts
,
mat
.
shape
[
1
]),
file
=
sys
.
stderr
)
matrices
.
append
(
mat
)
totalcols
=
sum
([
m
.
shape
[
0
]
for
m
in
matrices
])
...
...
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