yeatmanlab / pyAFQ

Automated Fiber Quantification ... in Python
http://yeatmanlab.github.io/pyAFQ/
BSD 2-Clause "Simplified" License
53 stars 34 forks source link

Use non-AFQ tensors #262

Closed TheJaeger closed 2 years ago

TheJaeger commented 4 years ago

Hi! I work with Drs. Jensen and Helpern at MUSC and I've been attempting to run AFQ for one of our studies. The restriction here is that we want to use tensors produced by PyDesigner. I've looked through the pyAFQ code but wasn't able to find any means to define custom tensors. Is there any provision to do this?

PyDesigner produces DT.nii for DTI, and additionally KT.nii if DKI is possible. These tensors are formatted the same way as MRtrix3:

The tensor coefficients are stored in the output image as follows:
volumes 0-5: D11, D22, D33, D12, D13, D23

If diffusion kurtosis is estimated using the -dkt option, these are stored as follows:
volumes 0-2: W1111, W2222, W3333
volumes 3-8: W1112, W1113, W1222, W1333, W2223, W2333
volumes 9-11: W1122, W1133, W2233
volumes 12-14: W1123, W1223, W1233
arokem commented 4 years ago

Hi @TheJaeger! Thanks for getting in touch. This is not currently a part of the CLI, but we should make it easy for users to input their volume of scalars into the CLI as file-paths.

Presumably, this would be another folder in the derivatives folder, with a similar structure to the dmriprep folder that would be automatically crawled by the software.

To understand your use-case a little bit better, I have a couple of questions: Would your needs be met if we provide estimates of DKI scalars, calculated using the DIPY implementation? We already have MD and FA calculated with DKI implemented (so if you provide 'DKI_FA' and 'DKI_MD' as part of the scalars input, you should get these in your tract profiles. It would be relatively straightforward to add other scalars from the DIPY DKI implementation.

arokem commented 4 years ago

Also, in a pinch, for the time being, with a little bit of programming, you can follow the example provided in DIPY to extract tract profiles for combinations of TRK files and nifti volumes: https://dipy.org/documentation/1.1.1./examples_built/afq_tract_profiles/

TheJaeger commented 4 years ago

It would be a great idea to add importing of our own scalars, @arokem - this is what we require for our needs. We prefer using DTI and DKI scalar outputs from PyDesigner instead of DIPY since we have greater control over the calculations being performed. Perhaps a Python dictionary with paths to custom scalars would be a good way to do this as AFQ.dti.fit_dti already produces a dict of paths.

I'll follow that DIPY example in the meantime to see if I can get any viable results. Thanks for linking it.

arokem commented 4 years ago

Just sketching this out, I think that what we want is something like:

[bundles]
scalars = ['dti_fa', 'dti_md']
extra_scalars =  {'my_scalar': 'path/to/derivatives/scalars'}

where the key is going to be the name of the scalar (e.g., this will be the name of the scalar in the CSV files), and the value is a path to a folder that is structured as follows:

path/to/derivatives/scalars/ sub1 sub2/sess1/ sess2/sub2_sess2_dwi_model-MOD_foo.nii.gz /sub2_sess2_dwi_model-MOD_bar.nii.gz ... ...

I think that the tricky bit would be to support having more than one scalar, but we could parse that and do my_scalar_foo and my_scalar_bar. Would that work for you? I noticed that you mentioned that you have tensor elements. Do you also have scalars computed from these tensor elements?

On Thu, May 14, 2020 at 9:00 AM Siddhartha Dhiman notifications@github.com wrote:

It would be a great idea to add importing of our own scalars, @arokem https://github.com/arokem - this is what we require for our needs. We prefer using DTI and DKI scalar outputs from PyDesigner instead of DIPY since we have greater control over the calculations being performed. Perhaps a Python dictionary with paths to custom scalars would be a good way to do this as AFQ.dti.fit_dti already produces a dict of paths.

I'll follow that DIPY example in the meantime to see if I can get any viable results. Thanks for linking it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yeatmanlab/pyAFQ/issues/262#issuecomment-628729896, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA46NQNPPVRZCLR2R7MMODRRQIRVANCNFSM4NACFPWA .

TheJaeger commented 4 years ago

This sounds good. And yes, we do have all DTI/DKI scalars computed from the tensor.

LMK if you'd like more assistance with this.

36000 commented 2 years ago

Custom scalars now implemented.