automagic "slicing" of physio recordings into BIDS

98 views
Skip to first unread message

yarikoptic

unread,
Apr 10, 2017, 9:39:48 PM4/10/17
to bids-discussion
Before I attempted to even to try it, given a good amount of wikis/notes on the issue of physio recordings, I wondered if there might be already (or may be it is not possible due to some issues such as clock skew) a script which given

1. a BIDS dataset (with proper sidecar files with AcquisitionDateTime and possible additional fields such as time:samples:AcquisitionTime) so it is possible to determine DICOM time for each sequence/volume
2. collection of Siemens physio recordings logs (with LogStartMDHTime and LogStopMDHTime fields presumably corresponding to DICOM clock) which were acquired during the entire scanning session

"slices" those physio recordings into corresponding BIDS _physio files ?



rorden

unread,
Apr 11, 2017, 8:38:05 AM4/11/17
to bids-discussion
I think the definitive guide for Siemens is here
As both you and that web page note, you need to use the MDHTime not MPCUTime to avoid timing drift between the DICOM and physiological recording clocks. I did write a cross-platform executable that reads Philips and Siemens physic files, which might be useful but is not actively maintained and is much more verbose than a typical modern scripting language 

Edward J. Auerbach notes for the popular CMRR sequences: "R015 adds one significant new feature: physiological data can now be saved to a special DICOM file stored in the image database, which should be easier to handle than individual text files. This new feature is only available for VD13x/VE11x syngo versions. Sample Matlab code for reading and converting these files is provided in the GitHub repository. (Note that the file format is not the same as the Siemens WiP which has similar functionality.)" with Matlab code at https://github.com/CMRR-C2P/MB

Yaroslav Halchenko

unread,
Apr 11, 2017, 9:11:44 AM4/11/17
to bids-discussion
Thank you Chris!

On Tue, 11 Apr 2017, rorden wrote:
> I think the definitive guide for Siemens is here
> https://cfn.upenn.edu/aguirre/wiki/public:pulse-oximetry_during_fmri_scanning
> As both you and that web page note, you need to use the MDHTime

Thanks! I think I originally scraped that knowledge off one of your
pages which was very informative. Thanks for Aguirre's page -- will go
through it ("... saved in VoxBo REF file format" raised my eye brow
though since Daniel IIRC is long time at google somewhere )

> not MPCUTime to avoid timing drift between the DICOM and physiological
> recording clocks. I did write a cross-platform executable that reads
> Philips and Siemens physic files, which might be useful but is not actively
> maintained and is much more verbose than a typical modern scripting
> language
> https://github.com/neurolabusc/Part

NB at some point I will show off my MS DOS high school project
program I wrote in Turbo Pascal having seen no linux or windows -- just
black screen of MSDOS! I am still very proud of myself on that
achievement

I guess you have no conscious plans to improve/maintain it? My Pascal
foo predates all my kids ages taken together ;)

I guess, if no other tool is out there, someone would need to (re)code
that conversion within BIDS suite of tools (I guess within pybids)

> Edward J. Auerbach notes for the popular CMRR sequences: "R015 adds one
> significant new feature: physiological data can now be saved to a special
> DICOM file stored in the image database, which should be easier to handle
> than individual text files. This new feature is only available for
> VD13x/VE11x syngo versions. Sample Matlab code for reading and converting
> these files is provided in the GitHub repository. (Note that the file
> format is not the same as the Siemens WiP which has similar
> functionality.)" with Matlab code at https://github.com/CMRR-C2P/MB

Finally! but unfortunately I don't think we are using any of those
sequeneces (CCing our mr-physicist for definite nack)

--
Yaroslav O. Halchenko
Center for Open Neuroscience http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419
WWW: http://www.linkedin.com/in/yarik

rorden

unread,
Apr 11, 2017, 9:45:53 AM4/11/17
to bids-discussion
I think you would just have to translate the tiny function loadSiemensPhysio() to your favorite language. One option would be to translate it to C (think of Pascal as a vetoes form of C with better portability and string handling) and insert it into dcm2niix (which can already write BIDS JSON files). As I recall, all you need to record is the LogStartMPCUTime, LogStopMPCUTime, and then filter the input physic signal to remove timing flags from the raw data. The pseudo-code would look something like this

//vector is input signal with nVectorItems datapoints
//outVector is output signal stripped of timing flags
int o = 0; //number of elements in output array
bool lSkipValues = false;
for (int i = 0, i < nVectorItems, i++)  
if (vector[i] == 6002) 
    lSkipValues = false;
    elseif (vector[i] == 5002)
    lSkipValues = true;
    elseif (vector[i] == '5003') 
    break; //end of recording
    elseif (lSkipValues == false) {
    outVector[o] = vector[i];
    o++;
    }
}   
Reply all
Reply to author
Forward
0 new messages