Timeseries Analysis¶
- CPAC.timeseries.gen_roi_timeseries(data_file, template, output_type)[source]¶
Method to extract mean of voxel across all timepoints for each node in roi mask
- Parameters:
data_file (
string
) – path to input functional datatemplate (
string
) – path to input roi mask in functional native spaceoutput_type (
list
) – list of two boolean values suggesting the output types - numpy npz file and csv format
- Returns:
out_list – list of 1D file, txt file, csv file and/or npz file containing mean timeseries for each scan corresponding to each node in roi mask
- Return type:
- Raises:
- CPAC.timeseries.gen_vertices_timeseries(rh_surface_file, lh_surface_file)[source]¶
Method to extract timeseries from vertices of a freesurfer surface file
- Parameters:
rh_surface_file (
string (mgz/mgh file)
) – left hemisphere FreeSurfer surface filelh_surface_file (
string (mgz/mgh file)
) – right hemisphere FreeSurfer surface file
- Returns:
out_list – list of vertices timeseries csv files
- Return type:
string (list
offile)
- CPAC.timeseries.gen_voxel_timeseries(data_file, template)[source]¶
Method to extract timeseries for each voxel in the data that is present in the input mask
- Parameters:
datafile (
string (nifti file)
) – path to input functional datatemplate (
string (nifti file)
) – path to input mask in functional native spaceoutput_type (
list
) – list of two boolean values suggesting the output types - numpy npz file and csv format
- Returns:
out_list – Based on ouput_type options method returns a list containing path to npz and csv file having timeseries of each voxel in the data that is present in the input mask.The row header corresponds to voxel’s xyz cordinates and column headers corresponds to the volume index in the csv. By default it outputs afni compatible 1D file with mean of timeseries of voxels across timepoints.
- Return type:
list
offiles
- Raises:
- CPAC.timeseries.get_roi_timeseries(wf_name='roi_timeseries')[source]¶
Workflow to extract timeseries for each node in the ROI mask. For each node, mean across all the timepoint is calculated and stored in csv and npz format.
- Parameters:
wf_name (
string
) – name of the workflow- Returns:
wflow – workflow object
- Return type:
workflow object
Notes
Workflow Inputs:
inputspec.rest : string (nifti file) path to input functional data inputspec.output_type : string (list of boolean) list of boolean for csv and npz file formats input_roi.roi : string (nifti file) path to ROI mask
Workflow Outputs:
outputspec.roi_ts : numpy array Voxel time series stored in numpy array, which is used to create ndmg graphs. outputspec.roi_outputs : string (list of files) Voxel time series stored in 1D (column wise timeseries for each node), csv and/or npz files. By default it outputs timeseries in a 1D file. The 1D file is compatible with afni interfaces.
Example
>>> import CPAC.timeseries.timeseries_analysis as t >>> wf = t.get_roi_timeseries() >>> wf.inputs.inputspec.rest = '/home/data/rest.nii.gz' >>> wf.inputs.input_roi.roi = '/usr/local/fsl/data/atlases/HarvardOxford/HarvardOxford-cort-maxprob-thr0-2mm.nii.gz' >>> wf.inputs.inputspec.output_type = [True,True] >>> wf.base_dir = './' >>> wf.run()
- CPAC.timeseries.get_spatial_map_timeseries(wf_name='spatial_map_timeseries')[source]¶
Workflow to regress each provided spatial map to the subjects functional 4D file in order to return a timeseries for each of the maps
- Parameters:
wf_name (
string
) – name of the workflow- Returns:
wflow – workflow object
- Return type:
workflow object
Notes
Workflow Inputs:
inputspec.subject_rest : string (nifti file) path to input functional data inputspec.subject_mask : string (nifti file) path to subject functional mask inputspec.spatial_map : string (nifti file) path to Spatial Maps inputspec.demean : Boolean control whether to demean model and data
Workflow Outputs:
outputspec.subject_timeseries: string (txt file) list of time series stored in a space separated txt file the columns are spatial maps, rows are timepoints
Example
>>> import CPAC.timeseries.timeseries_analysis as t >>> wf = t.get_spatial_map_timeseries() >>> wf.inputs.inputspec.subject_rest = '/home/data/rest.nii.gz' >>> wf.inputs.inputspec.subject_mask = '/home/data/rest_mask.nii.gz' >>> wf.inputs.inputspec.ICA_map = '/home/data/spatialmaps/spatial_map.nii.gz' >>> wf.inputs.inputspec.demean = True >>> wf.base_dir = './' >>> wf.run()
- CPAC.timeseries.get_vertices_timeseries(wf_name='vertices_timeseries')[source]¶
Workflow to get vertices time series from a FreeSurfer surface file
- Parameters:
wf_name (
string
) – name of the workflow- Returns:
wflow – workflow object
- Return type:
workflow object
Notes
Workflow Inputs:
inputspec.lh_surface_file : string (nifti file) left hemishpere surface file inputspec.rh_surface_file : string (nifti file) right hemisphere surface file
Workflow Outputs:
outputspec.surface_outputs: string (csv and/or npz files) list of timeseries matrices stored in csv and/or npz files
Example
>>> import CPAC.timeseries.timeseries_analysis as t >>> wf = t.get_vertices_timeseries() >>> wf.inputs.inputspec.lh_surface_file = '/home/data/outputs/SurfaceRegistration/lh_surface_file.nii.gz' >>> wf.inputs.inputspec.rh_surface_file = '/home/data/outputs/SurfaceRegistration/rh_surface_file.nii.gz' >>> wf.base_dir = './' >>> wf.run()
- CPAC.timeseries.get_voxel_timeseries(wf_name='voxel_timeseries')[source]¶
Workflow to extract time series for each voxel in the data that is present in the input mask
- Parameters:
wf_name (
string
) – name of the workflow- Returns:
wflow – workflow object
- Return type:
workflow object
Notes
Workflow Inputs:
inputspec.rest : string (nifti file) path to input functional data inputspec.output_type : string (list of boolean) list of boolean for csv and npz file formats input_mask.masks : string (nifti file) path to ROI mask
Workflow Outputs:
outputspec.mask_outputs: string (1D, csv and/or npz files) list of time series matrices stored in csv and/or npz files.By default it outputs mean of voxels across each time point in a afni compatible 1D file. High Level Workflow Graph:
Example
>>> import CPAC.timeseries.timeseries_analysis as t >>> wf = t.get_voxel_timeseries() >>> wf.inputs.inputspec.rest = '/home/data/rest.nii.gz' >>> wf.inputs.input_mask.mask = '/usr/local/fsl/data/standard/MNI152_T1_2mm_brain.nii.gz' >>> wf.inputs.inputspec.output_type = [True,True] >>> wf.base_dir = './' >>> wf.run()