QMICodeBase / TORTOISEV4

Official TORTOISE Diffusion MRI Processing Pipeline V4 Source Code and Documentation
GNU General Public License v3.0
18 stars 4 forks source link

Error processing rodent data #8

Open araikes opened 10 months ago

araikes commented 10 months ago

Hi @eurotomania

I was trying to test TORTOISEProcess with some rodent data and I run into this error right off the bat:

terminate called after throwing an instance of 'nlohmann::detail::type_error'
  what():  [json.exception.type_error.302] type must be array, but is number
Aborted

I converted my data with brkraw and I know that this is mad about the JSON file and something in it but I don't know what field it's expecting as an array. Is there any way to track it down?

Thanks

EBHutchinson commented 4 months ago

Hi @araikes I'm trying to get v4 up and running for Bruker data also. Not sure if you are still at it, but if so... I ran into this problem too. It looks like the json parameter PartialFourier is given as an array by brkraw as something like

"PartialFourier": [ 1.6, 1 ],

When I change it to

"PartialFourier": 1

The error is gone. It seems to be the opposite solution as the error implies, but it works.

@eurotomania - ^^^yes??? Is there a better way to fix it?

eurotomania commented 4 months ago

Wooow.

That is very interesting. Honestly, for data like that (where you have full control over), I would just used the CreateDummyJson executable to create a json file with the parameters you enter. That is why it exists.

On Wed, Mar 6, 2024 at 5:22 PM EBHutchinson @.***> wrote:

Hi @araikes https://github.com/araikes I'm trying to get v4 up and running for Bruker data also. Not sure if you are still at it, but if so... I ran into this problem too. It looks like the json parameter PartialFourier is given as an array by brkraw as something like

"PartialFourier": [ 1.6, 1 ],

When I change it to

"PartialFourier": 1

The error is gone. It seems to be the opposite solution as the error implies, but it works.

@eurotomania https://github.com/eurotomania - ^^^yes??? Is there a better way to fix it?

— Reply to this email directly, view it on GitHub https://github.com/eurotomania/TORTOISEV4/issues/8#issuecomment-1981932312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFQZWBWZEFBI72BLNXTM7TYW6JLLAVCNFSM6AAAAAA32HTPNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBRHEZTEMZRGI . You are receiving this because you were mentioned.Message ID: @.***>

-- M. Okan Irfanoglu Graduate Student & GTA Computer Sciences & Engineering Ohio State University

EBHutchinson commented 4 months ago

Thanks, is there an example or template json file we could base that on? Or just a list of json parameters required for v4 and their type? Couldn't find this info elsewhere. Not to jinx it, but the rest of TORTOISEProcess actually ran well with the brkraw import including diffprep/drbuddi, still have to check directions.

eurotomania commented 4 months ago

YEs I am still in the process of writing a description/example file for every executable. So they are not al there yet.

But an example would be:

CreateDummyJson -i myDWI.nii -p j+ -m 1 -f 1

This creates a json file with the same base name as DWIs, vertical phase encoding, no multiband and partial fourier of 1.

On Thu, Mar 7, 2024 at 11:00 AM EBHutchinson @.***> wrote:

Thanks, is there an example or template json file we could base that on? Or just a list of json parameters required for v4 and their type? Couldn't find this info elsewhere. Not to jinx it, but the rest of TORTOISEProcess actually ran well with the brkraw import including diffprep/drbuddi, still have to check directions.

— Reply to this email directly, view it on GitHub https://github.com/eurotomania/TORTOISEV4/issues/8#issuecomment-1983833189, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFQZWDH73XNQMLFCJPCHXTYXCFJRAVCNFSM6AAAAAA32HTPNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBTHAZTGMJYHE . You are receiving this because you were mentioned.Message ID: @.***>

-- M. Okan Irfanoglu Graduate Student & GTA Computer Sciences & Engineering Ohio State University

EBHutchinson commented 4 months ago

Ok, great, thanks. I tried the following and it worked (!) so should also for others with up/down Bruker data from PV360.

(final?) remaining question - is the delta in ms or s (I assume s, so 0.005 for 5ms little delta)?

Here is what worked for me...

after brkraw for import, assume ${UPprefix}, ${DOWNprefix} are the full paths to the up/down file names (without extension) and ${STR} is the structural image (nii) and ${MASK} is a mask I made from the up dwis in itksnap.

CreateDummyJson -i ${UPprefix}.nii -p i+ -f 0.625 --big_delta .012 --small_delta .005 here -f should be 1/Bruker Fourier acceleration, note: Gibbs correction won't run for 1.5 or more, probably thats fine. here -p i+ was left/right phase here d=5ms, D=12ms I assume units are in seconds, right?

Then I run the following to process

TORTOISEProcess -u ${UPprefix}.nii --up_json ${UPprefix}.json --ub ${UPprefix}.bval --uv ${UPprefix}.bvec -d ${DOWNprefix}.nii --db ${DOWNprefix}.bval --dv ${DOWNprefix}.bvec -s ${STR} --b0_mask_img ${MASK} --denoising for_final --is_human_brain 0 -c motion --DRBUDDI_DWI_bval_tensor_fitting 2100 -o ${OUT};

This worked well for me. I'm including image screenshots for DRBUDDI below.

DRBUDDI01

The FA map looks good, but the DEC map is wrong. This is probably due to import of the bvecs and I expect it is not something fixable within TORTOISE, probably depends more on brkraw. Expected and solvable, but if there is a general fix, I can post a different thread. See below

DTI01

eurotomania commented 4 months ago

Great.

HOWEVER.. The deltas are in ms. So it should be 5 not 0.005.

I assume the import was wrong for bvecs/bvals.

First, you need to find the correct order of swap/flip. Then you can either use the executable FlipSwapBMatrix or you can do that directly while calling TORTOISEProcess (this option will be uploaded in like 5 minutes. I was literally working on that for another user).

Examples: FlipSwapBMatrix --input_bmtxt my_orig.bmtxt --output_bmtxt my_final.bmtxt --X y --Y x --Z -z This swaps X and Y gradients and flips the Z gradient.

IF you want to do this in TORTOISE part:

TORTOISEProcess your_input_paramters ........................... --swapXY 1 --flipZ 1 (but again this will be pushed later today.... You will need to do another git pull and compile).

On Thu, Mar 7, 2024 at 1:02 PM EBHutchinson @.***> wrote:

Ok, great, thanks. I tried the following and it worked (!) so should also for others with up/down Bruker data from PV360.

(final?) remaining question - is the delta in ms or s (I assume s, so 0.005 for 5ms little delta)?

Here is what worked for me...

after brkraw for import, assume , are the full paths to the up/down file names (without extension) and is the structural image (nii) and is a mask I made from the up dwis in itksnap.

CreateDummyJson -i .nii -p i+ -f 0.625 --big_delta .012 --small_delta .005 here -f should be 1/, note: Gibbs correction won't run for 1.5 or more, probably thats fine. here -p i+ was left/right phase here d=5ms, D=12ms I assume units are in seconds, right?

Then I run the following to process

TORTOISEProcess -u ${UPprefix}.nii --up_json ${UPprefix}.json --ub ${UPprefix}.bval --uv ${UPprefix}.bvec -d ${DOWNprefix}.nii --db ${DOWNprefix}.bval --dv ${DOWNprefix}.bvec -s ${STR} --b0_mask_img ${MASK} --denoising for_final --is_human_brain 0 -c motion --DRBUDDI_DWI_bval_tensor_fitting 2100 -o ${OUT};

This worked well for me. I'm including image screenshots for DRBUDDI below.

DRBUDDI01.png (view on web) https://github.com/eurotomania/TORTOISEV4/assets/53198381/79889093-6270-4f70-a41e-94e572e5ca34

The FA map looks good, but the DEC map is wrong. This is probably due to import of the bvecs and I expect it is not something fixable within TORTOISE, probably depends more on brkraw. Expected and solvable, but if there is a general fix, I can post a different thread. See below

DTI01.png (view on web) https://github.com/eurotomania/TORTOISEV4/assets/53198381/954afffa-3220-476b-9810-795648034c97

— Reply to this email directly, view it on GitHub https://github.com/eurotomania/TORTOISEV4/issues/8#issuecomment-1984132628, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFQZWEGBXDWHKFHKFACLATYXCTSPAVCNFSM6AAAAAA32HTPNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBUGEZTENRSHA . You are receiving this because you were mentioned.Message ID: @.***>

-- M. Okan Irfanoglu Graduate Student & GTA Computer Sciences & Engineering Ohio State University

araikes commented 3 months ago

@EBHutchinson

If you open your NIFTI using nibabel and let me know the axis codes. I can probably give you a start on the rotation. I've worked them out out for all of my sequences.

import nibabel as nb
input_img = nb.load(<path/to/nifti>)
nb.aff2axcodes(input_img.affine)