[Neuroimaging] [dipy] Import csd model precomputed by mrtrix

Ariel Rokem arokem at gmail.com
Fri May 27 08:23:38 EDT 2016


Hi Paolo,

Thanks for the update. Sorry to hear it didn't work as hoped.

On Fri, May 27, 2016 at 2:07 AM, Paolo Avesani <avesani at fbk.eu> wrote:

> Thanks for your replies.
> A brief update.
>
> Samuel is right. I have in mind to manage the multi-shell model from
> mrtrix3.
> It is clear that up to now it is not viable until the work in progress
> from Bago becomes available.
>
> I tried to follow the example suggested by Ariel, focusing on a single
> shell csd model (coming from dwi2fod command of mrtrix3),
> and setting the sphere as the one used by mrtrix3 (a 300 points). The
> "predict" method raised an issue of disalignment of matrix size.
>
> The issue is at line 217 of csdecon.py when a product between
> "predict_matrix" and "sh_coeff" takes place.
> The "predict matrix" has size (90,45): 90 volumes, 45 sh
> The "sh_coeff" has size (145, 174, 145, 45): the xyz dimensions of the
> volume, 45 sh
>
> It looks the size of predict matrix is wrong. It should be
> (145,174,145,90).
>
>
>
Or the predict_matrix should be (45, 90)? Would be useful if you shared a
minimal example that raises this error.

Cheers,

Ariel



>
>
> On Thu, May 26, 2016 at 4:07 AM, Samuel St-Jean <stjeansam at gmail.com>
> wrote:
>
>> Indeed, I thought I read the multitissue version was used here, my
>> mistake as the question does not directly imply that.
>>
>> The regular single shell hopefully does the same (at least I can
>> personally attest the mrtrix2 version and dipy version give similar fodf up
>> to a small rounding factor, but that was before the cholesky decomposition
>> step, so now they should behave the same).
>> On May 26, 2016 09:37, "Bago" <mrbago at gmail.com> wrote:
>>
>>> Samuel mrtrix has at least two models implemented. The multi-shell
>>> (multi-tissue) model cannot be used with single shell data and the original
>>> CSD model cannot be used with multi-shell data.
>>>
>>> Bago
>>>
>>> On Wed, May 25, 2016 at 5:13 PM Samuel St-Jean <stjeansam at gmail.com>
>>> wrote:
>>>
>>>> Their wiki explains it, a sqrt(2) to normalize is used in mrtrix3, so
>>>> multiplying your coefficients with that and using the mrtrix2 functions
>>>> should do it.
>>>>
>>>> Although dipy only does single shell, so conclude with consideration
>>>> that the algorithm is different from mrtrix3. Also, csd is a bad signal
>>>> predictor (but good for angle estimation), see the sparc dmri challenge
>>>> paper for example.
>>>> On May 26, 2016 07:55, "Ariel Rokem" <arokem at gmail.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Wed, May 25, 2016 at 4:41 PM, Bago <mrbago at gmail.com> wrote:
>>>>>
>>>>>> I believe they did change their basis (please correct me if I'm wrong
>>>>>> but I believe they went from a non-normalized SH basis to a normalized SH
>>>>>> basis).
>>>>>>
>>>>>>
>>>>> So they have the same basis as dipy now, but the coefficients appear
>>>>> in a different order? That should make life even easier!
>>>>>
>>>>>
>>>>>> Also projecting onto a sphere is one way to _estimate_ the
>>>>>> coefficients in a different basis. The cleaner way is to just re-order the
>>>>>> coefficients and apply the appropriate scaling. If both basis are
>>>>>> normalized (which dipy is) the scaling should be 1 or -1.
>>>>>>
>>>>>>
>>>>> Fair point, but to be just a little bit facetious: given enough points
>>>>> on the sphere and knowledge of the target maximal order of the
>>>>> coefficients, wouldn't estimating be the same as transforming? Works for
>>>>> the FFT, I believe :-)
>>>>>
>>>>> Bago
>>>>>>
>>>>>> On Wed, May 25, 2016 at 3:31 PM Ariel Rokem <arokem at gmail.com> wrote:
>>>>>>
>>>>>>> On Wed, May 25, 2016 at 1:09 PM, Bago <mrbago at gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi Paolo,
>>>>>>>>   mrtrix and dipy define the SH basis slightly differently, so the
>>>>>>>> precomputed FOD values need to be adjusted if you want to skip the fit step
>>>>>>>> and initialize the Fit object directly. IRC we don't currently have the
>>>>>>>> code to do that, but it would be something we'd like to incorporate.
>>>>>>>>
>>>>>>>> Did they change their basis set when they transitioned to mrtrix3?
>>>>>>> We do have these functions:
>>>>>>>
>>>>>>>
>>>>>>> https://github.com/nipy/dipy/blob/master/dipy/reconst/shm.py#L852-L923
>>>>>>>
>>>>>>> That should work with the previous version of mrtrix (mrtrix2?). You
>>>>>>> can use these to transform between coefficient sets:
>>>>>>>
>>>>>>>     sf = sh_to_sf(mrtrix_coeffs, sphere, sh_order,
>>>>>>> basis_type='mrtrix')
>>>>>>>     dipy_coeffs = sf_to_sh(sf, sphere, sh_order, basis_type=None) #
>>>>>>> This defaults to the dipy basis set
>>>>>>>
>>>>>>> and then use the CSD model object to predict:
>>>>>>>
>>>>>>>     from dipy.reconst.csdeconv import
>>>>>>>  ConstrainedSphericalDeconvModel
>>>>>>>     csd_model = ConstrainedSphericalDeconvModel(gtab, response,
>>>>>>> sh_order=sh_order) # Note: you still need to calculate the response
>>>>>>> function!
>>>>>>>     pred_signal = csd_model.predict(dipy_coeffs, gtab, S0)
>>>>>>>
>>>>>>> I think that something like this should work (but I haven't tried it
>>>>>>> myself).
>>>>>>>
>>>>>>>
>>>>>>>> I have a WIP version of the multi-shell CSD model on a separate
>>>>>>>> branch, I plan on merging it but wasn't intending to get to that for a few
>>>>>>>> months. If you'd like to look at before then I can push the branch up to
>>>>>>>> github.
>>>>>>>>
>>>>>>>> Sounds interesting! I'd love to see what you have so far!
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Ariel
>>>>>>>
>>>>>>>
>>>>>>>> Bago
>>>>>>>>
>>>>>>>> On Wed, May 25, 2016 at 2:31 AM Paolo Avesani <avesani at fbk.eu>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> I would like to take advantage of the "predict" method of
>>>>>>>>> reconstruction models in dipy. The goal is to assess the quality of results.
>>>>>>>>>
>>>>>>>>> I have already computed the reconstruction models using mrtrix3
>>>>>>>>> and stored the ODF files. For this reason I would need to initialize the
>>>>>>>>> csd model by importing the data from ODF stored by mrtrix3.
>>>>>>>>>
>>>>>>>>> The questions are manifold:
>>>>>>>>> - may I initialize the csd model by providing the precomputed
>>>>>>>>> values and skipping the "fit" step?
>>>>>>>>> - may I import the value of precomputed model from a file stored
>>>>>>>>> by mrtrix3?
>>>>>>>>> - is the csd model in dipy compliant with the output of
>>>>>>>>> multi-shell csd model computed by mrtrix3?
>>>>>>>>>
>>>>>>>>> I hope my questions and my goal is formulated clearly.
>>>>>>>>> Thanks for your support.
>>>>>>>>> Paolo
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Neuroimaging mailing list
>>>>>>>>> Neuroimaging at python.org
>>>>>>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Neuroimaging mailing list
>>>>>>>> Neuroimaging at python.org
>>>>>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>> Neuroimaging mailing list
>>>>>>> Neuroimaging at python.org
>>>>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Neuroimaging mailing list
>>>>>> Neuroimaging at python.org
>>>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Neuroimaging mailing list
>>>>> Neuroimaging at python.org
>>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>>
>>>>> _______________________________________________
>>>> Neuroimaging mailing list
>>>> Neuroimaging at python.org
>>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>>
>>>
>>> _______________________________________________
>>> Neuroimaging mailing list
>>> Neuroimaging at python.org
>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>>
>>>
>> _______________________________________________
>> Neuroimaging mailing list
>> Neuroimaging at python.org
>> https://mail.python.org/mailman/listinfo/neuroimaging
>>
>>
>
>
> --
> -------------------------------------------------------
> Paolo Avesani
> Fondazione Bruno Kessler
> via Sommarive 18,
> 38050 Povo (TN) - I
> phone:   +39 0461 314336
> fax:        +39 0461 302040
> email:     avesani at fbk.eu
> web:       avesani.fbk.eu
>
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20160527/b560a676/attachment.html>


More information about the Neuroimaging mailing list