Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: retrieving metadata from bids-formatted json files #27

Merged
merged 24 commits into from
Oct 25, 2021

Conversation

nbeliy
Copy link

@nbeliy nbeliy commented May 26, 2021

get_metadata_val is splitted into 3 functions:

  • get_metadata_val_classic -- original code of get_metadata_val
  • get_metadata_val_header -- retrieve metadata from nifti
  • get_metadata_val_bids -- retrieve metadata from bidsified json

The get_metadata_val checks if received structure contains 'acqpar' and based on it calls one of 3 functions.
This is needed because BIDS forces SI units in his metadata, while hMRI uses most convenient units (often ms).
Some of field names coincides between hMRI and BIDS, so we must know beforehand if which data is it.

get_metadata adds new field filename to returned structure, containing the filename of current file.
It is not the most elegant solution and can hide some fields in structure.
But it is needed because BIDS stores some information in filename (for ex modality) and separate files (bval and vec).

I tested it on one file and it returns same values for hMRI header and BIDS values for majority cases. Exceptions are:

  • RepetitionTimes -- not defined in BIDS, in local (CRC) bidsified are stored in RepetitionTimeSeries
  • EchoTimes -- same as above
  • ProtocolName -- not defined in BIDS
  • PhaseEncodingDirection -- in hMRI results contains space 'ROW ', while in BIDS it is without (not sure if it is important)
  • NumberOfMeasurements not BIDS
  • NumberOfSlices not BIDS
  • PATparameters not BIDs
  • AccelFactorPE not BIDS (possibly corresponds to MultibandAccelerationFactor)
  • AccelFactor3D not BIDS (possibly corresponds to MultibandAccelerationFactor)
  • WipParameters not BIDS
  • DiffusionDirection retrieved from bvec with some indexing
  • BValue same as above
  • epiReadoutDuration related to TotalReadoutDuration but not exactly the same

Beliy Nikita and others added 15 commits March 18, 2021 11:55
get_metadata_val is splitted into 3 functions:
  get_metadata_val_classic -- original code of get_metadata_val
  get_metadata_val_header -- retrive metadata from nifti
  get_metadata_val_bids -- retrive metadata from bidsified json

The get_metadata_val checks if recieved structure contains
'acqpar' and based on it colls one of 3 functions
Added:

 - isDWI from filename suffix
 - AllDiffusionDirections from bvec file
 - AllDiffusionValues from bval file

In order to get this info, added a new field to meta structure:
'filename' containing the path to data file.

bval and bvec are retrieved by changing extension
When possible the metadata structure is loaded and passed to the 'classic' or 'BIDS' get_metadata_val subfunctions.
Since there should not be any direct call to this function with a filename, one can remove the reloading of the mstruct based on a filename.
This is NOT in BIDS spaces but could be useful for some old data. It's only an added features and does not break back compatibility.
After looking for the 'TotalReadoutTime' field, one need to load the associated value then proceed.
…liy-get-metadata-bids

Synchronising master branches
@lukeje lukeje changed the title WIP: retrieving metadata from b-ds-formatted json files WIP: retrieving metadata from bids-formatted json files Jul 20, 2021
@lukeje
Copy link
Member

lukeje commented Jul 20, 2021

FYI, based on https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/01-magnetic-resonance-imaging-data.html I think "AccelFactorPE" corresponds to "ParallelReductionFactorInPlane" with "ParallelAcquisitionTechnique=GRAPPA". There seems to be no variable for parallel reduction factor in 3D, so AccelFactor3D might have to go in "MultibandAccelerationFactor" (though I'm not particularly happy with that, as the physics is actually different between multiband and 3D GRAPPA).

Beliy Nikita and others added 5 commits July 22, 2021 12:23
Slightly more informative error message if number of images and angles don't match; using assert syntax (rather than "if X, then error"); replaced a couple of "echo1", "echo2" in comments that had been missed; matched indexing of P to the rest of the code (avoiding potential errors if P given as 1xN array); no longer need to account for possibility of "extra" elements in the P array (because of explicit assert statement).
Copy link
Member

@lukeje lukeje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable for work-in-progress. Could maybe do with more explicit documentation in spm12/metadata/get_metadata_val_bids.m

@nbeliy
Copy link
Author

nbeliy commented Jul 27, 2021

These was a really stupid mistakes
I take that if in file there only one function, it's name don't matter?

@lukeje
Copy link
Member

lukeje commented Jul 27, 2021

These was a really stupid mistakes
I take that if in file there only one function, it's name don't matter?

Yes, exactly. It first searches local scope for any functions with that name, then searches for files with that name and calls the first function defined in the file, regardless of what it is "called".

Luke Edwards and others added 4 commits July 27, 2021 14:16
Copy link
Contributor

@mfcallaghan mfcallaghan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at hMRI hackathon; tested on hMRI example dataset and multiple CRC datasets. No conflicts or issues identified.

@DerOrfa DerOrfa merged commit 2c55bb3 into master Oct 25, 2021
@mfcallaghan mfcallaghan mentioned this pull request Oct 25, 2021
@mfcallaghan mfcallaghan deleted the beliy-get-metadata-bids branch October 25, 2021 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants