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
Christoph Arthofer
ms_templates
Commits
aaa659cb
Commit
aaa659cb
authored
Apr 22, 2021
by
Christoph Arthofer
Browse files
fslsub
parent
83494392
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
aaa659cb
...
...
@@ -142,28 +142,10 @@ Contains the output of the first set of rigd and affine registrations including
-
unbiased average T1 template in the unbiased space of the subjects
-
rigid transformation of unbiased template to MNI space
#### `affine_it1`
#### `affine_it2`
affine_it2 (affine_it2_dir)
{sub_id} (affine_it2_subject_dir)
T1_to_MNI152{ext_mat} (T1_to_MNI_mat)
T1_brain_to_MNI152{ext_nii} (T1_brain_to_MNI_img)
T1_head_to_MNI152{ext_nii} (T1_head_to_MNI_img)
T1_brain_mask_to_MNI152{ext_nii} (T1_brain_mask_to_MNI_img)
T2_FLAIR_to_MNI152{ext_mat} (T2_to_MNI_mat)
T2_FLAIR_brain_to_MNI152{ext_nii} (T2_brain_to_MNI_img)
T2_FLAIR_head_to_MNI152{ext_nii} (T2_head_to_MNI_img)
DTI_to_MNI152{ext_mat} (DTI_to_MNI_mat)
DTI_to_MNI152{ext_nii} (DTI_to_MNI_img)
DTI_tensor_to_MNI152{ext_nii} (DTI_tensor_to_MNI)
affine_template_T1_brain{ext_nii} (T1_brain_affine_template)
affine_template_T1_brain_mask{ext_nii} (T1_brain_mask_affine_template)
affine_template_T1_brain_mask_weighted{ext_nii} (T1_brain_mask_weighted_affine_template)
affine_template_T1_head{ext_nii} (T1_head_affine_template)
affine_template_T2_head{ext_nii} (T2_head_affine_template)
affine_template_DTI{ext_nii} (DTI_affine_template)
affine_template_DTI_tensor{ext_nii} (DTI_tensor_affine_template)
run_template_construction.py
View file @
aaa659cb
...
...
@@ -13,6 +13,9 @@ import shutil
import
pandas
as
pd
import
nibabel
as
nib
import
numpy
as
np
import
shlex
import
subprocess
import
sys
from
fsl.wrappers
import
fslmaths
,
flirt
,
applyxfm
,
concatxfm
,
bet
,
fast
,
fslstats
from
fsl.wrappers.fnirt
import
invwarp
,
applywarp
,
convertwarp
from
file_tree
import
FileTree
...
...
@@ -21,7 +24,7 @@ from fsl.utils.fslsub import func_to_cmd
from
operator
import
itemgetter
import
tempfile
import
argparse
import
sys
#
import
fsl_sub
def
writeConfig
(
step
,
mod
,
fpath
):
"""! Writes the nonlinear registration parameters for a given resolution level and modalities to a file readable by MMORF.
...
...
@@ -413,6 +416,66 @@ def applyWarpWrapper(img_path, ref_path, warped_path, warp_path, interp='spline'
applywarp
(
src
=
img_nib
,
ref
=
ref_path
,
out
=
warped_path
,
warp
=
warp_path
,
interp
=
interp
)
# def submitJob_fsl_sub(name, log_dir, queue, wait_for=[], script=None, command=None, coprocessor_class=None, export_var=None,
# debug=False):
# """! Wrapper for fslsub - submits a job to the cluster. This function can be easily extended to work with other workload managers.
#
# @param name: Job name
# @param log_dir: Directory where output log-files will be saved
# @param queue: Name of queue to submit the job to
# @param wait_for: List of IDs of jobs required to finish before running this job.
# @param script: Path to a shell script, which contains one command per line - commands will be submitted as an array job
# @param command: Alternatively a single command can be provided as a string - command will be submitted as single job
# @param coprocessor_class: Coprocessor class, if not None cuda will be selected
# @param export_var: Environment variables to be exported to the submission node
# @param debug: If True, information about job will be written to output
#
# @return The job ID.
# """
#
# fsl_sub.submit()
#
# cmd = 'fsl_sub'
# if wait_for and any(job != '' for job in wait_for):
# cmd += ' -j '
# for j, job in enumerate(wait_for):
# if job != '':
# cmd += job.replace("\n", "")
# if j < len(wait_for) - 1:
# cmd += ','
#
# cmd += ' -N ' + name + \
# ' -l ' + log_dir + \
# ' -q ' + queue
#
# if coprocessor_class is not None :
# cmd += ' --coprocessor cuda'
#
# if export_var is not None :
# cmd += ' --export ' + export_var
#
# if debug:
# cmd += ' --debug'
#
# if script is not None and os.path.exists(script):
# cmd += ' -t ' + script
# elif command is not None :
# cmd += shlex.split(command)
#
# # stream = os.popen(cmd)
# # job_id = stream.read()
#
# try:
# result = subprocess.run(command, capture_output, text=True, check=True)
# except subprocess.CalledProcessError as e:
# print(str(e), file=sys.stderr)
# return None
#
# job_id = result.stdout.strip()
#
# return job_id
def
submitJob
(
name
,
log_dir
,
queue
,
wait_for
=
[],
script
=
None
,
command
=
None
,
coprocessor_class
=
None
,
export_var
=
None
,
debug
=
False
):
"""! Wrapper for fslsub - submits a job to the cluster. This function can be easily extended to work with other workload managers.
...
...
@@ -442,25 +505,34 @@ def submitJob(name, log_dir, queue, wait_for=[], script=None, command=None, copr
' -l '
+
log_dir
+
\
' -q '
+
queue
if
coprocessor_class
!=
None
:
if
coprocessor_class
is
not
None
:
cmd
+=
' --coprocessor cuda'
if
export_var
!=
None
:
if
export_var
is
not
None
:
cmd
+=
' --export '
+
export_var
if
debug
:
cmd
+=
' --debug'
if
script
!=
None
and
os
.
path
.
exists
(
script
):
if
script
is
not
None
and
os
.
path
.
exists
(
script
):
cmd
+=
' -t '
+
script
elif
command
!=
None
:
cmd
+=
' "'
+
command
+
'"'
elif
command
is
not
None
:
cmd
+=
shlex
.
split
(
command
)
# stream = os.popen(cmd)
# job_id = stream.read()
stream
=
os
.
popen
(
cmd
)
job_id
=
stream
.
read
()
try
:
result
=
subprocess
.
run
(
command
,
capture_output
,
text
=
True
,
check
=
True
)
except
subprocess
.
CalledProcessError
as
e
:
print
(
str
(
e
),
file
=
sys
.
stderr
)
return
None
job_id
=
result
.
stdout
.
strip
()
return
job_id
def
RMSdifference
(
img1_path
,
img2_path
,
mask1_path
=
None
,
mask2_path
=
None
,
rms_path
=
None
):
"""! Calculates the difference between two images or warps as the root mean squared (RMS)
...
...
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