Jfortin1 / ComBatHarmonization

Harmonization of multi-site imaging data with ComBat
268 stars 107 forks source link

Detection of single batch in one site so var() calculation is not needed #37

Open judychen7652 opened 2 years ago

judychen7652 commented 2 years ago

Hi Jfortin1,

I've been using combat to harmonize multisite MRI data and it has been very helpful so far! However, I recently ran into a bit of trouble after limiting my cohort for further analyses. I kept getting an error that points me to line 80 in the combat.m function:

delta_hat = [];
    for i=1:n_batch
        indices = batches{i};
        delta_hat = [delta_hat; var(s_data(:,indices)')];
    end

After some digging, I realize that for single column entries in a batch, var() would calculate the column variance as opposed to row variance which I assume would happen if there were more column entries in the batch. Would you be able to quickly amend this part to include situations illustrated above?

Thanks so much for the great work! Hope to hear back from you soon!!

Sincerely, Judy