-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Dockerfile edit * Add cpac-necessary libraries to Dockerfile * add initial functional pipeline scripts * fix typo * fix docker typos * fix cpac directory organization * add no-caching on pip installations and apt-get clean * adapt directorysweeper to handle fmri data, initial fmri pipeline funcitons added * initial working prototype of m2g_func_worker * add s3 push capabilities to functional pipeline * add input arguments for functional pipeline * add info to acquisition input argument * update m2g_cloud funcitons for new functional pipeline * typo fix * Update m2g_pipeline.yaml * change script to go up to 10 GB memory per participant * changes to cpac parameters to allow ec2 instances to function * add functional pipeline local batch running * ec2 test * remove memory limitation * add gigabyte control to f-pipeline * add n_cpu control * fix cpac terminal call typo * derek_changes * final configuration edits * add more specific parameters to crawl_bucket * Priebe edits (#396) * necessary changes to allow large parcellations to run * typo fix * typo fix * allow multiple parcellations to be run * add csv import * version lock cpac * Update Dockerfile Fix dockerfile to take from deploy branch of neuroparc and m2g * Update m2g_func.py Add function descriptions
- Loading branch information
Showing
13 changed files
with
1,470 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
m2g.functional | ||
~~~~~~~~~~~~ | ||
Contains scripts for running the functional pipeline. | ||
m2g_func : top-level pipeline entrypoint | ||
""" | ||
|
||
from . import m2g_func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import subprocess | ||
import yaml | ||
from m2g.utils.gen_utils import run | ||
|
||
def make_dataconfig(input_dir, sub, ses, anat, func, acquisition='alt+z', tr=2.0): | ||
"""Generates the data_config file needed by cpac | ||
Arguments: | ||
input_dir {str} -- Path of directory containing input files | ||
sub {int} -- subject number | ||
ses {int} -- session number | ||
anat {str} -- Path of anatomical nifti file | ||
func {str} -- Path of functional nifti file | ||
acquisition {str} -- acquisition method for funcitonal scan | ||
tr {float} -- TR (seconds) of functional scan | ||
Returns: | ||
None | ||
""" | ||
|
||
Data = [{ | ||
'subject_id': sub, | ||
'unique_id': f'ses-{ses}', | ||
'anat': anat, | ||
'func': { | ||
'rest_run-1': { | ||
'scan': func, | ||
'scan_parameters': { | ||
'acquisition': acquisition, | ||
'tr': tr | ||
} | ||
} | ||
} | ||
}] | ||
|
||
config_file = f'{input_dir}/data_config.yaml' | ||
with open(config_file,'w',encoding='utf8') as outfile: | ||
yaml.dump(Data, outfile, default_flow_style=False) | ||
|
||
return config_file | ||
|
||
|
||
def make_script(input_dir, output_dir, subject, session, data_config, pipeline_config, mem_gb, n_cpus): | ||
cpac_script = '/root/.m2g/cpac_script.sh' | ||
with open(cpac_script,'w+',encoding='utf8') as script: | ||
script.write(f'''#! /bin/bash | ||
. /venv/bin/activate | ||
python /code/run.py --data_config_file {data_config} --pipeline_file {pipeline_config} --n_cpus {n_cpus} --mem_gb {mem_gb} {input_dir} {output_dir} participant | ||
''') | ||
|
||
run(f'chmod +x {cpac_script}') | ||
|
||
return cpac_script | ||
|
||
|
||
|
||
def m2g_func_worker(input_dir, output_dir, sub, ses, anat, bold, acquisition, tr, mem_gb, n_cpus): | ||
"""Creates the requisite files to run CPAC, then calls CPAC and runs it in a terminal | ||
Arguments: | ||
input_dir {str} -- Path to input directory | ||
output_dir {str} -- Path to output directory | ||
sub {int} -- subject number | ||
ses {int} -- session number | ||
anat {str} -- Path of anatomical nifti file | ||
bold {str} -- Path of functional nifti file | ||
acquisition {str} -- Acquisition method for funcitional scans | ||
tr {str} -- TR time, in seconds | ||
""" | ||
|
||
pipeline_config='/m2g/m2g/functional/m2g_pipeline.yaml' | ||
|
||
data_config = make_dataconfig(input_dir, sub, ses, anat, bold, acquisition, tr) | ||
cpac_script = make_script(input_dir, output_dir, sub, ses, data_config, pipeline_config,mem_gb, n_cpus) | ||
|
||
# Run pipeline | ||
subprocess.call([cpac_script], shell=True) |
Oops, something went wrong.