Donders-Institute / bidscoin

BIDScoin converts your source-level neuroimaging data to BIDS
https://bidscoin.readthedocs.io
GNU General Public License v3.0
129 stars 35 forks source link

Take the `dir` value from dcm2niix's sidecar file #201

Closed marcelzwiers closed 1 year ago

marcelzwiers commented 1 year ago

Is your feature request related to a problem? Please describe. The DICOM header does not directly store the phase encoding direction op EPI image to populate the dir-AP/PA or dir-LR/RL key-value pairs.

Describe the solution you'd like Dcm2niix retrieves the dir information indirectly and stores it as PhaseEncodingDirection: j/j- and PhaseEncodingDirection: k/k- respectively (for axial acquisitions at least). So BIDScoin could retrospectively use that info to dynamically update dir: <<PhaseEncodingDirection>>

This could perhaps become a generic feature, e.g. of the form dir: <<sidecar:PhaseEncodingDirection>> or dir: <<<PhaseEncodingDirection>>>

marcelzwiers commented 1 year ago

Implementation of <<<*>>> makes most sense and is very easy -- all that is needed is this:

    def dynamicvalue(self, value, cleanup: bool=True, runtime: bool=False):
        """
        [...]
        """

        # Input checks
        if not value or not isinstance(value, str) or not self.path.name or ('<<<' in value and '>>>' in value):
            return value

Together with adding post-dynamic value renaming code to: bids.increment_runindex(outfolder, newbidsname, sidecarname, ..)

But I'm dropping this idea after all because the sidecar value from dcm2niix ({"PhaseEncodingDirection": "j-"}) contains BIDS-invalid +/- signs and therefore cannot be used in the filename *_dir-sidecarvalue_