User Tools

Site Tools


biac:analysis:physiological

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
biac:analysis:physiological [2011/10/25 19:19]
petty [AFNI]
biac:analysis:physiological [2023/02/23 18:43] (current)
Line 1: Line 1:
 ====== Physiological Correction Methods ====== ====== Physiological Correction Methods ======
  
-Currently this assumes that you have recorded your physiological responses through Cigal.  Also, these types of corrections should be done **before** any type of slice-time correction or pre-processing.+===== Generate resampled TSV from raw GE physio files automatically copied from the scanners  =====
  
-There's a python program, than can take your run's bxh header along with your cigal pdigm file to create various types of corrected text files to be used for physio corrections in a number of different packages.+Stock GE physio is hardcoded by GE to be 25Hz for respiration and 100Hz for pulse.  The continuous gating files will start 30 seconds before the scan is triggered.
  
-This tools uses various fields from the bxh and pdigm file to output "corrected" data.  "Corrected" here means accounting for potential time locking issues, different TR in the cigal recording verses the actual data acquisition, ddqs, etc. 
- 
-The python tool will call cigal functions directly, then output new text data in the format requested. 
  
 <code> <code>
-physio_create.py --help+[cmp12@blade17 20211218_03399]$ /usr/local/packages/biacpython/bin/convert_GEphysio.py --help 
 +usage: convert_GEphysio.py [-h] --xmlh XMLFNAME [--json JSONFNAME] --physdir 
 +                           PHYSDIR [--bidsout] [--afnislicetime] 
 +                           [--delay DELAYTIME] 
 + 
 +create 100Hz resampled TSV from raw GE physio data 
 + 
 +optional arguments: 
 +  -h, --help         show this help message and exit 
 +  --xmlh XMLFNAME    BXH data 
 +  --json JSONFNAME   JSON data 
 +  --physdir PHYSDIR  physio directory 
 +  --bidsout          write BIDS specific TSV data and json sidecar 
 +  --afnislicetime    write AFNI slicetiming 1D files for RetroTS and tshift 
 +  --delay DELAYTIME  time past ending time of functional to end search for 
 +                     matching physio files 
 </code> </code>
 +
 +Provide a valid BXH ( and JSON if possible ) and a path to your subject physio folder to convert_GEphysio.py function.  If the BXH does not contain slice timing information the JSON is required.
 +
 +This function will search the physio directory for physio files within a specified time range based on the functional scantime + timepoints + a default delay in writing.
 +
 +If matching respiration and pulse files are found theoretical scan triggers on each TR will be created and the respiration and pulse data will be resampled to 100Hz and locked to the onset of the scan.  If disdaqs are detected in the BXH the corresponding physio time will be discarded.
  
 <code> <code>
-physio_create.py --bxh /path/to/run4.bxh --pdigm /path/to/pdigm5_12345_4_2 -f fsl --outpath /here/+/usr/local/packages/biacpython/bin/convert_GEphysio.py --xmlh Data/Func/20211218_03399/bia6_03399_004_01.bxh --physdir Data/Func/20211218_03399 --bidsout 
 +</code>
  
-Program to produce formatted physiological data: +By default you will get a 100Hz resampled TSV with headers and timing.
-    Data will be corrected and recreated from the pdigm file based on information from run data +
-    BXH and PDIGM required +
-    OUTPATH defaults to PWD +
-    FORMAT: defaults to fsl +
-        - fsl = cardio,resp,TR pulse ( 3 column file )  +
-        - npm = time,cardio,resp ( 3 column file ) +
-        - afni = cardiac.txt, respiration.txt+
  
  
-Options: +The **--bidsout** flag will output a TSV without headers and a BIDS sidecar with appropriate column labels and sampling frequency.
-  -h, --help            show this help message and exit +
-  -b FILE, --bxh=FILE   bxh file for run +
-  -p FILE, --pdigm=FILE +
-                        pdigm file for run +
-  -f string, --format=string +
-                        output format ( fsl,npm,afni ) +
-  -o PATH, --outpath=PATH +
-                        location to store output files+
  
-</code> 
  
-===== AFNI =====+The **--afnislicetime** flag will output two 1D slicetiming files to be used with RetroTS.py and afni_proc.py directly.
  
-Create the AFNI formated physiological text data. +=== Using afni ===
-<code bash>physio_create.py -b Data/Func/20111025_12345/run004.bxh -p Data/Behav/12345/pdigm5_12345_4_2 -f afni</code>+
  
-This would create my "cardiac.txt" and "respiration.txt".+You can create regressors for afni preprocessing from output files above using RetroTS.py
  
-Now set-up build the regressors that will be used in afni with their matlab tool.+<code> 
 +python3 /usr/local/packages/afni/21.1.04/RetroTS.py -phys_file series013_01_physio.tsv -phys_json series013_01_physio.json -n 42 -v 2 -slice_order series013_01_slicetimingV.1D -prefix  series013_01
  
-<code matlab> +-n #slices 
-addpath /usr/local/packages/MATLAB/afni/ +-v TR in seconds
-Opt.Respfile = '/tmp/there/respiration.txt' +
-Opt.Cardfile = '/tmp/there/cardiac.txt' +
-Opt.VolTR = 1.5 +
-Opt.Nslices = 34 +
-Opt.PhysFS = 100+
  
-RetroTS(Opt) 
 </code> </code>
  
-The output will be "oba.slibase.1D", which is a text file containing regressors to remove from your data on a slice-by-slice basis.+RetroTS will produce "slibase" regressors to be used with retroicor during afni preprocessing, or afni retroicor regression 
  
-Convert your data to 4D nifti if you haven't already done so: 
-<code bash>bxh2analyze --niigz -s input.bxh run004</code> 
  
-Create the afni script which you will use to actually run the 3dretroicor functionality: +=== setup afni despike, retroicor and slicetime correction ===
-<code bash>afni_proc.py -subj_id 12345 -dsets run004.nii.gz -blocks despike -do_block ricor -tcat_remove_first_trs 0 -ricor_regs *.slibase.1D -ricor_regs_nfirst 0 -ricor_regre +
-ss_method 'per-run'</code>+
  
-The result of the above command would be a tcsh script, which would run the despiking and 3dretroicor correction only.  Run it: 
-<code bash>tcsh -xef proc.12345 |& tee output.proc.12345</code> 
  
-There will be a resulting folder with all the afni data inside You can convert the afni BRIK to a nifti filethen wrap it with BXHthen proceed to whatever you're doing afterwards: +<code> 
-<code bash> +python3 /usr/local/packages/afni/21.1.04/afni_proc.py \ 
-#convert afni to nii, create bxh + -subj_id sub-00104_run-4_ricor_phys \ 
-3dAFNItoNIFTI 12345.results/pb02.12345.r01.ricor+orig.BRIK + -blocks despike ricor tshift \ 
-fslwrapbxh pb02.12345.r01.ricor.BRIK+ -dsets ../../../../BIDS/sub-00104/ses-01/func/sub-00104_ses-01_task-rest_run-4_bold.nii.gz \ 
 + -tcat_remove_first_trs 2 \ 
 + -tshift_opts_ts -tpattern @/mnt/munin/BIAC/SysService.01/Analysis/UHP/BIDS/sub-00104/ses-01/physio/series004_01_slicetiming.1D \ 
 + -ricor_regs_nfirst 2 \ 
 + -ricor_regs /mnt/munin/BIAC/SysService.01/Analysis/UHP/BIDS/sub-00104/ses-01/physio/series004_01.slibase.1D \ 
 + -verb 1 
 + 
 +</code> 
 + 
 +The above will produce an afni script to throw out 2 timepointsperform despikeretroicor physio regression and slice time correction based on the RetroTS output and the physio TSV/json above. 
 + 
 +Convert the afni corrected output back to nii.gz to be used for other pre-processing if not using AFNI for all steps 
 + 
 +<code> 
 +bxh2analyze --niigz -s pb03.sub-00104_run-4_ricor_phys.r01.tshift+orig.HEAD sub-00104_run-4_physiocorrected
 </code> </code>
 + 
  
-Run the resting state pipeline: 
-<code bash>resting_pipeline.py -f pb02.12345.r01.ricor.bxh -s 1,2,3,4,5,6,7 -p func --sliceorder odd</code> 
  
  
Line 85: Line 90:
  
  
 +====== CIGAL pdigm specific processing ======
 +[[biac:analysis:physiological:cigal_pdigm| CIGAL pdigm specific physio correction methods]]
  
biac/analysis/physiological.1319570360.txt.gz · Last modified: 2014/08/04 16:03 (external edit)