App::AFNI:SiemensPhysio - Physio from Siemens into format suitable for AFNI's RetroTS retroicor routine


Get slice based respiration volume per time (RVT) regressors from physio collected on Siemens scanner

  my $p = SiemensPhysio->new({VERB=>1});
  # read MR data (get times, TR, nslices)
  #  looks at all files in this directory with "dicom_hinfo"

  # read pulse
  # write card: $protocol_$sessionTime.puls.dat

  # read card
  # write resp: $protocol_$sessionTime.resp.dat


  # we could get the raw data 
  #   in this case, card was resp was loaded last
  #   thats what will be returned)
  my @pval = $p->getMRPhys();



read Siemens physio files
read timing from MR DICOM files
snip physio files relative to MR
prepare/run AFNI's RetroTS

prior art


initialize object



MDH (default) or MPCU


Physio sample rate defaults to .2

pulsStart and respStart numeric sequence to be remove, also identifies stream type


  pulsStart =>'1 2 40 280'
  respStart =>'1 2 20 2'

alt+z (default) other options: alt-z,seq+z,seq-z,filename # slice order


set to true to be verbose, defaults false


don't check sample rate and index count against end-start time none=> check both MR => trust MR (TR) phys=> trust physio (PhRate as set by init) all => trust both

Note: just have to match reg exp, so MRphys is same as all


after intializing p, provide a file name


input file format

 1 2 40 280 ... [long space delimn. list of measurements, maybe 5000 for trigger?]
 ECG  Freq Per: 0 0
 PULS Freq Per: 74 807
 RESP Freq Per: 20 2860
 EXT  Freq Per: 0 0
 ECG  Min Max Avg StdDiff: 0 0 0 0
 PULS Min Max Avg StdDiff: 527 1586 828 4
 RESP Min Max Avg StdDiff: 2380 6700 3477 86
 EXT  Min Max Avg StdDiff: 0 0 0 0
 NrTrig NrMP NrArr AcqWin: 0 0 0 0
 LogStartMDHTime:  66439690
 LogStopMDHTime:   71116595
 LogStartMPCUTime: 66439512
 LogStopMPCUTime:  71114802


after intializing p, read in MR info from raw DICOM directory



timing (MRstart and MRend)
protcol info (protocol,TR,ET,nslices,Series)

Example Info

dicom header info

  dicom_hdr MRRaw/10824_20111108/rest_384x384.21/MR* |egrep 'protocol|acquisition Time|Echo Time|Repetition Time' -i
    0008 0031       14 [620     ] //                 ID Series Time//164627.359000
    0008 0032       14 [642     ] //            ID Acquisition Time//164932.315000 
    0018 0080        4 [1418    ] //            ACQ Repetition Time//1500
    0018 0081        2 [1430    ] //                  ACQ Echo Time//29
    0018 1030        4 [1612    ] //              ACQ Protocol Name//rest
    0019 100a        2 [1788    ] //                               // 29

shortend to

  dicom_hinfo -tag 0008,0032 0008,0031 0018,0080 0018,0081 0018,1030 MR*

readBIDSJson read TR MRstart and crate MRend from BIDS style json output (e.g. created by dcm2niix).

must already have nDcms (number of volumes in 4d) set


write phys during MR to file works on most recently loaded physio file

use getMRphys to get values
use writeDat to write values


This is kludgy code hacked together and untested :) =over

use a bunch of hacks to find the matlab binary
construct a matlab call using options in self object
execute matlab or McRetroTS
move outputs to fit local naming convention

get/run command to get Resp. Vol./Time (RVT) via AFNI's retroTS a la MUST have already read MR and written card and resp dat files


how this step is handled is defined by the first argument

matlab: use RetroTS.m
McRetroTs: use compiled matlab verson of RetroTS.m
show: print commands for both matlab and McRetroTS
none: do nothing (why'd you call me then!?)

External Commands


if using matlab+retroTS, the path to retroTS.m should be in your MATLABPATH export MATLABPATH="$HOME/afni_matlab/matlab/:$MATLABPATH"

1 POD Error

The following errors were encountered while parsing the POD:

Around line 439:

'=item' outside of any '=over'