rpomponio / neuroHarmonize

Harmonization tools for multi-site neuroimaging analysis. Implemented as a python package. Harmonization of MRI, sMRI, dMRI, fMRI variables with support for NIFTI images. Complements the work in Neuroimage by Pomponio et al. (2019).
https://pypi.org/project/neuroHarmonize/
MIT License
82 stars 28 forks source link

More than one variable in smooth_terms #35

Closed mblesac closed 7 months ago

mblesac commented 1 year ago

Hi,

I can run the code with one variable in smooth_terms, however when I do:

my_model, nifti_array_adj = nh.harmonizationLearn(nifti_array, covars, smooth_terms=['AGE_B', 'AGE_S'])

It gives me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/EBC/local/fsl/lib/python3.10/site-packages/neuroHarmonize/harmonizationLearn.py", line 130, in harmonizationLearn
    bs = BSplines(X_spline, df=[10] * len(smooth_cols), degree=[3] * len(smooth_cols),
  File "/EBC/local/fsl/lib/python3.10/site-packages/statsmodels/gam/smooth_basis.py", line 929, in __init__
    super(BSplines, self).__init__(x, include_intercept=include_intercept,
  File "/EBC/local/fsl/lib/python3.10/site-packages/statsmodels/gam/smooth_basis.py", line 757, in __init__
    self.smoothers = self._make_smoothers_list()
  File "/EBC/local/fsl/lib/python3.10/site-packages/statsmodels/gam/smooth_basis.py", line 935, in _make_smoothers_list
    kwds = self.knot_kwds[v] if self.knot_kwds else {}
IndexError: list index out of range

Do you know what is causing this issue? Thanks in advance.

Bst regards,

Manuel

rpomponio commented 9 months ago

I don't believe this package will support more than one smooth term in its current implementation. I will keep this issue open for now as an idea for further development.

However, I would ask why you need more than one smooth term for age in your model... the inclusion of a smooth term will flexibly fit a non-linear age trend. I don't immediately see a need for more than one smooth term in this example.

mblesac commented 8 months ago

Hi,

The reason for this is that I was working with neonatal data. With this data we usually take into account two ages, the age at scan and the age at birth, both are important and affect the diffusion metrics. So I was trying to harmonize different datasets fitting two non-linear age relations.

Best regards,

Manuel