Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Detrend optimally combined data before running PCA #1090

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tedana/decomposition/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import pandas as pd
from mapca import MovingAveragePCA
from nilearn.signal import standardize_signal
from scipy import stats
from sklearn.decomposition import PCA

Expand Down Expand Up @@ -204,12 +205,11 @@ def tedpca(
f"Computing PCA of optimally combined multi-echo data with selection criteria: {algorithm}"
)
data = data_oc[mask, :]

data_z = ((data.T - data.T.mean(axis=0)) / data.T.std(axis=0)).T # var normalize ts
data_z = (data_z - data_z.mean()) / data_z.std() # var normalize everything
data_z = standardize_signal(data.T, detrend=True, standardize="zscore_sample").T
# data_z = (data_z - data_z.mean()) / data_z.std() # var normalize everything
tsalo marked this conversation as resolved.
Show resolved Hide resolved

if algorithm in ["mdl", "aic", "kic"]:
data_img = io.new_nii_like(io_generator.reference_img, utils.unmask(data, mask))
data_img = io.new_nii_like(io_generator.reference_img, utils.unmask(data_z, mask))
tsalo marked this conversation as resolved.
Show resolved Hide resolved
mask_img = io.new_nii_like(io_generator.reference_img, mask.astype(int))
ma_pca = MovingAveragePCA(criterion=algorithm, normalize=True)
_ = ma_pca.fit_transform(data_img, mask_img)
Expand Down