# Lmax choice for msdwi2fod

Dear team,

How is `-lmax` set for `msdwi2fod`? In my experiments I found that for most of the subjects it was set to to 8 resulting in 45 coefficients except for one for which it was set to 6 resulting in 28 coefficients. I found this out when I was trying to use `mrmath` to take a mean of a set of subjects’ FODs.

Could you let me know how best to proceed? Enforcing `-lmax` to 8 or trying to adjust response function estimation somehow so that `-lmax` would be set to 8 internally?

Thanks so much!
Sincerely,
Nagesh

Hi Nagesh,

There’s a few different factors at play here, so I’ll try to split the answer up into digestible portions. This is probably also a good candidate for a documentation entry If it is not set explicitly by the user using the `-lmax` option, lmax is selected as follows:

• Determine the maximum value for lmax that is supported by the number of DWI volumes in the shell being processed (or the total number of non-b=0 volumes in a single-shell acquisition). This is the number of coefficients required to store an anitipodally-symmetric spherical harmonic function:
``````lmax | Required volumes
-----------------------
2 | 6
4 | 15
6 | 28
8 | 45
10 | 66
12 | 91
... | ...
``````
• If lmax exceeds 8 (and again, if the user has not explicitly set `-lmax`), reduce to 8. This is primarily based on the findings in this paper.

• Check the condition of the transformation between DWIs and spherical harmonics. If the transformation is ill-conditioned (usually indicating that the diffusion sensitisation gradient directions are not evenly distributed over the sphere or half-sphere), reduce lmax until the transformation is well-conditioned. As an example: concatenating two repeats of a 30 direction acquisition to produce 60 volumes will not support an lmax=8 fit: the angular resolution of the data set is equivalent to 30 unique directions, and so lmax=6 would be selected (and this would be accompanied by a command-line warning).

• In the case of spherical deconvolution, the lmax selected for FOD estimation will also be reduced if lmax of the provided response function is less than that calculated as above.

Any command dealing with spherical harmonic data should provide an `-lmax` option. However the capabilities of this option depends on the command:

• The way that response function estimation is currently implemented, it is impossible to set lmax to a value higher than that supported by your number of volumes. The transformation from DWI data to spherical harmonics simply cannot be done in such a case, as the problem is under-determined. You can of course set a lower lmax than that supported by the data.

• In spherical deconvolution, it is possible to set a higher lmax than that supported by the data - so-called super-resolved spherical deconvolution. Here, additional information is provided by the non-negativity constraint to make estimation of additional spherical harmonic coefficients possible. However this is not guaranteed: sometimes the algorithm will fail, in cases where there are an insufficient number of directions in which the initial FOD estimate is negative, as the problem remains under-determined.

But back to your question: If lmax has been reduced for a single subject only, the most likely explanation is that the scan was terminated prematurely for that subject, such that they have a reduced number of volumes. How to deal with that is up to you; but if it’s only single subject within a reasonably-sized cohort, I’d be leaning towards exclusion of that subject.

Cheers
Rob

1 Like

Hi Rob,

Thanks so much for the wonderful answer. Very very helpful!

Sincerely,
Nagesh