Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fsl_mrs
Commits
0b90dd77
Commit
0b90dd77
authored
Jun 16, 2020
by
William Clarke
Browse files
Fix mrsi_segment.
parent
905a4dd5
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl_mrs/scripts/mrsi_segment
View file @
0b90dd77
...
...
@@ -12,8 +12,11 @@
import
argparse
import
os.path
as
op
from
os
import
remove
from
fsl.wrappers
import
flirt
,
fsl_anat
,
fslroi
from
fsl.wrappers
import
fsl_anat
,
fslroi
from
fsl.wrappers.fnirt
import
applywarp
from
subprocess
import
call
import
numpy
as
np
from
fsl.data.image
import
Image
def
main
():
...
...
@@ -44,37 +47,28 @@ def main():
anat
=
args
.
anat
# Make dummy nifti as nothing works with complex data
call
([
'fslcomplex'
,
'-realabs'
,
args
.
mrsi
,
op
.
join
(
args
.
output
,
'tmp.nii.gz'
)])
call
([
'fslcpgeom'
,
args
.
mrsi
,
op
.
join
(
args
.
output
,
'tmp.nii.gz'
)])
fslroi
(
op
.
join
(
args
.
output
,
'tmp.nii.gz'
),
op
.
join
(
args
.
output
,
'tmp.nii.gz'
),
0
,
1
)
mrsi_in
=
Image
(
args
.
mrsi
)
tmp_img
=
np
.
zeros
(
mrsi_in
.
shape
[
0
:
3
])
tmp_img
=
Image
(
tmp_img
,
xform
=
mrsi_in
.
voxToWorldMat
)
tmp_img
.
save
(
op
.
join
(
args
.
output
,
'tmp.nii.gz'
))
# Register the pvseg to the MRSI data using flirt
def
flirt_func
(
i
,
o
):
flirt
(
i
,
op
.
join
(
args
.
output
,
'tmp.nii.gz'
),
out
=
o
,
usesqform
=
True
,
applyxfm
=
True
,
noresampblur
=
True
,
interp
=
'nearestneighbour'
,
setbackground
=
0
,
paddingsize
=
1
)
def
applywarp_func
(
i
,
o
):
applywarp
(
i
,
op
.
join
(
args
.
output
,
'tmp.nii.gz'
),
o
,
usesqform
=
True
,
super
=
True
,
superlevel
=
'a'
)
# T1_fast_pve_0, T1_fast_pve_1, T1_fast_pve_2
# partial volume segmentations (CSF, GM, WM respectively)
flirt
_func
(
op
.
join
(
anat
,
'T1_fast_pve_0.nii.gz'
),
op
.
join
(
args
.
output
,
args
.
filename
+
'_csf.nii.gz'
))
flirt
_func
(
op
.
join
(
anat
,
'T1_fast_pve_1.nii.gz'
),
op
.
join
(
args
.
output
,
args
.
filename
+
'_gm.nii.gz'
))
flirt
_func
(
op
.
join
(
anat
,
'T1_fast_pve_2.nii.gz'
),
op
.
join
(
args
.
output
,
args
.
filename
+
'_wm.nii.gz'
))
applywarp
_func
(
op
.
join
(
anat
,
'T1_fast_pve_0.nii.gz'
),
op
.
join
(
args
.
output
,
args
.
filename
+
'_csf.nii.gz'
))
applywarp
_func
(
op
.
join
(
anat
,
'T1_fast_pve_1.nii.gz'
),
op
.
join
(
args
.
output
,
args
.
filename
+
'_gm.nii.gz'
))
applywarp
_func
(
op
.
join
(
anat
,
'T1_fast_pve_2.nii.gz'
),
op
.
join
(
args
.
output
,
args
.
filename
+
'_wm.nii.gz'
))
remove
(
op
.
join
(
args
.
output
,
'tmp.nii.gz'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment