ohbm / hackathon2019

Website and projects for the OHBM Hackathon in Rome 2019
https://ohbm.github.io/hackathon2019
81 stars 61 forks source link

BIDS-ifying the hMRI toolbox #74

Open ChristophePhillips opened 5 years ago

ChristophePhillips commented 5 years ago

BIDS-ifying the hMRI toolbox

Project Description

The hMRI toolbox allows you to generate quantitative MRI data from a series of "raw" multi-echo structural images and field maps, i.e. the Multi-Parametric Mapping (MPM) protocol. So far, the toolbox is not BIDS compliant but it would clearly help everyone if it did...

hMRI_mapcreation

Skills required to participate

Anyone with some experience in Matlab, quantitative MRI, SPM-extension toolbox development or the will to learn these skills.

Integration

The hMRI project has been supported by a few labs already and used by a few more. Harmonizing the way the sequence parameters are saved and accessed would help data management, QA, and sharing.

One BIDS Extension Proposal (BEP001) focuses on standardizing such structural acquisitions that include multiple contrasts (multi echo, flip angle, inversion time) sequences. This effort thus aims at integrating the hMRI toolbox within the BEP001. The latter is still in development, therefore adjustments if needed are still possible.

Intermediate steps:

Preparation material

The public distribution of hMRI toolbox code is available here but I'll make the latest private version available for the development. Example data are available here, specifically the "800µm 64 channel protocol" data set.

sitek commented 5 years ago

Hi @ChristophePhillips – I'm interested in working on this since I recently collected MPM data (and ran into BIDS conversion–hMRI toolbox compatibility). I'm at the second hackathon site (Una Deco) right now – will you be working on this this afternoon?

ChristophePhillips commented 5 years ago

Hi Kevin (@sitek), Happy to catch up wherever. :-) I am at the Mercado Central and I think lunch will be served here for everyone. So we could certainly meet up then. Otherwise I'll just "cross the street" and find you at Una Deco.

sitek commented 5 years ago

So far I have a heuristic file that follows the BIDS Extension Proposal, which is used by heudiconv to convert the dicoms to niftis: https://gist.github.com/sitek/61cdd1e89b4c9435b113292d9fc983f8

However, this leads to hMRI Toolbox processing issues, where it appears some sensors are ignored/incorrectly incorporated. (I mentioned this on the mailing list a couple months ago.) Meanwhile, running the toolbox with hMRI/SPM-converted niftis works great. The images themselves appear identical, so there must be a difference in the JSONs created by heudiconv (a wrapper for dcm2niix) and by the hMRI Toolbox.

If we could nail down those JSON differences, that would be a good first step.

ChristophePhillips commented 5 years ago

Ha yes, @satra mentioned the issue to me this morning... We should definitely sit down and check those data! Tomorrow morning, right after breakfast, to get started ?

Have you diff-ed the 2 types (dcm2nii vs. spm_convert) of JSON files ? The toolbox is quite "touchy" with the MR acquisition parameters. It will also typically fall back on some defaults, if it can't fond what it needs... which may lead to some problems. :-/

sitek commented 5 years ago

Sounds good! I'll be at Mercato.

The JSON files are really quite different – 65 lines vs. 1730 lines (dcm2niix vs spm_convert), for instance. Not many keys are shared between them, either. If you can help me get an intuition for how the toolbox uses the JSON items, that would be very helpful!

sitek commented 5 years ago

Looks like dcm2niix converts TE and TR in seconds, not ms: image (paused hmti_create_MTProt.m after line 92 and saved mpm_params using both conversion versions)

ChristophePhillips commented 5 years ago

Doooh! Actually all time metadata should be expressed in seconds BUT hMRI, at least in the public version, uses ms for historical reasons. This is the kind of discrepancies that should disappear with a BIDS-compliant toolbox... Future releases should be using seconds.

A quick hack would be to re-scale the TE and TR appropriately in ms by *1000 (for the time being but after checking if the value is <1 for extra-safety). See around lines 106-123 in hmri_create_MTProt.m the ⬅'s:

% TE/TR/FA for each contrast % T1w and MTw contrasts are optional. % PDw must be present or nothing can be calculated. The script will abort % at the next line if no PDw echoes available. In that case, a warning has % been thrown earlier (in get_mpm_params). TE_pdw = mpm_params.input(PDwidx).TE; ⬅ TR_pdw = mpm_params.input(PDwidx).TR; ⬅ fa_pdw = mpm_params.input(PDwidx).fa; if T1widx TE_t1w = mpm_params.input(T1widx).TE; %#ok ⬅ TR_t1w = mpm_params.input(T1widx).TR; ⬅ fa_t1w = mpm_params.input(T1widx).fa; end if MTwidx TE_mtw = mpm_params.input(MTwidx).TE; %#ok ⬅ TR_mtw = mpm_params.input(MTwidx).TR; ⬅ fa_mtw = mpm_params.input(MTwidx).fa; end

Sorry for the trouble!

sitek commented 5 years ago

R1 and PD look great with this change. Unfortunately, R2s and MTsat do not – R2s has an odd dynamic range, and MTsat looks like a field map was poorly integrated. I'm guessing the B1 TE also needs to be adjusted from s to ms – I'll try changing config/local/hmri_b1_local_defaults.m here and see if that fixes it.

TinaUOL commented 2 years ago

Hi together, Are there any news on this project? I am trying to convert our hMRI data to the BIDS standard as well. I used dicm2nii to convert the data by using Matlab. However, when trying to create the maps, the following error occurred already at the beginning:

grafik

It seems that the HMRI toolbox still has some problems with different json files. Even after deleting this line at the beginning of each json file the error is still the same. There seems to be some "hidden" information also stored, but I can not find any differences in the .nii files. When importing the data using the hMRI DICOM import everything works perfectly.

Could someone help me with that issue? Or is it only possible to run the hMRI toolbox with the respective DICOM import. But shouldn't it be a goal of the BIDS STANDARD to standardize things?

Any help would be welcome.

Thanks in advance, Tina

mateuszpawlik commented 2 years ago

Hi everyone, are there any news? We've recently started collecting MPM data. I'm responsible for converting them to BIDS and working on an automatic solution. I currently use BIDScoin which executes dcm2niix in the background. hMRI-toolbox has two relevant issues open (20 and 45) but I don't see much development there.

Is there any comprehensive list of requirements from hMRI side? A list of required keys in json files and their provenance would be useful.

lukeje commented 1 year ago

@mateuszpawlik Some BIDS compatibility was added in this pull request in October 2021: https://github.com/hMRI-group/hMRI-toolbox/pull/27 The keys are specified here, if this is helpful: https://github.com/hMRI-group/hMRI-toolbox/blob/master/spm12/metadata/get_metadata_val_bids.m