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

The function adjust_data_final() in neuroCombat.py is modifying the input arg s_data #31

Closed gurayerus closed 9 months ago

gurayerus commented 1 year ago

In neuroCombat.py the function adjust_data_final() gets "s_data" as an input. The function modifies the contents of the array: bayesdata = s_data ... bayesdata[:,batch_idxs] = numer / denom Is this done on purpose?

Note: This part of the code comes from the initial implementation by JP Fortin. However, his code does not return or uses s_data, so there is no problem. In neuroHarmonize, there is an option to return s_data in neuroHarmonizeLearn(), and if the update of the s_data is not intentional, this will cause returning an incorrect s_data value.

rpomponio commented 1 year ago

If I understand correctly, you are asking whether the update to s_data is intentional. Yes, I believe so, since the function will either apply the adjustments for empirical bayes estimates of site effects (if eb is True) or it will apply adjustments based on location/scale estimates of site effects (if eb is False).

The ability to return s_data just enables users to work with the "standardized" data (zero mean and unit standard deviation, after correcting site effects) if they prefer so. The object bayes_data will be back-transformed to the mean and variance of the original data.