jmtyszka / bidskit

Utility functions for working with DICOM and BIDS neuroimaging data
MIT License
61 stars 41 forks source link

Fieldmap IntendedFor redux #20

Closed celstark closed 6 years ago

celstark commented 6 years ago

IntendedFor still needs two things, from what I can see: 1) Spitting out the full directory 2) Handling multiple runs smoothly

For example, my Protocol_Translator.json has a pair of sections like this, that I think are written as intended: "BOLD_PACal":[ "fmap", "dir-PA_epi", "task-baselines_bold" ], This leads to: "IntendedFor":"sub-121001_ses-Session1_task-baselines_bold.nii.gz"

In truth, given the multiple runs we had with the same name, it should read: "IntendedFor":["ses-Session1/func/sub-121001_ses-Session1_task-baselines_run-01_bold.nii.gz", "ses-Session1/func/sub-121001_ses-Session1_task-baselines_run-02_bold.nii.gz", "ses-Session1/func/sub-121001_ses-Session1_task-baselines_run-03_bold.nii.gz", "ses-Session1/func/sub-121001_ses-Session1_task-baselines_run-04_bold.nii.gz" ] So, we should both prepend the ses-session/func/ bit and we should append whatever runs we came up with.

jmtyszka commented 6 years ago

I've just pushed a potential fix for this issue, but because of the wide variety of approaches to naming and using fieldmaps with multiple EPI runs there are some provisos:

  1. The IntendedFor element in the protocol translator JSON allows for multiple entries, so if a single GRE field map or single pair of SE-EPI fieldmapping images is acquired and applied to a set of BOLD EPI runs, you'll need to list the EPI runs explicitly in the protocol translator.

  2. I'm going to make the (hopefully safe) assumption that fieldmaps acquired in one imaging session are not applied to EPI series in another session. This would be an edge case, since fieldmaps should be acquired close in time to the associated EPI series (for example, we acquire one fmap immediately before each BOLD EPI series in practice).

  3. In the example above, the protocol translator entry can now be:

    "BOLD_PACal" : [
    "fmap",
    "dir-PA_epi",
    ["task-baselines_run-01_bold",
     "task-baselines_run-02_bold",
     "task-baselines_run-03_bold", 
     "task-baselines_run-04_bold"]
    ]

    and this should generate the following in the JSON sidecar:

    "IntendedFor":["func/sub-121001_ses-Session1_task-baselines_run-01_bold.nii.gz", "func/sub-121001_ses-Session1_task-baselines_run-02_bold.nii.gz", "func/sub-121001_ses-Session1_task-baselines_run-03_bold.nii.gz", "func/sub-121001_ses-Session1_task-baselines_run-04_bold.nii.gz" ]

Note that the ses-Session1 folder shouldn't be specified (although that is allowed by the BIDS specification) for the reasoning above (edge case).