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

[ENH] Generate BIDS Derivatives-compatible outputs #691

Merged
merged 41 commits into from
May 5, 2021
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
21e479c
BIDS Derivatives-compatible outputs.
tsalo May 22, 2020
9dd2728
Fix outputs.
tsalo May 22, 2020
41c9512
Merge branch 'master' into ref/filenames-and-variables
tsalo Jul 13, 2020
66b0a0c
Fix filenames.
tsalo Jul 14, 2020
000997e
Merge branch 'master' into ref/filenames-and-variables
tsalo Sep 22, 2020
eb23f74
Merge branch 'master' into ref/filenames-and-variables
tsalo Oct 22, 2020
737b19c
Reformat MIR function with black.
tsalo Oct 22, 2020
0b82189
Update fiu_four_echo_outputs.txt
tsalo Oct 22, 2020
d00b03a
Merge branch 'main' into ref/filenames-and-variables
tsalo Feb 6, 2021
51c7a7b
Reorganize metric outputs.
tsalo Feb 6, 2021
65784d8
Write out PCA outputs.
tsalo Feb 7, 2021
7f88281
Fix tests.
tsalo Feb 7, 2021
141c1b1
Fix up gscontrol.
tsalo Feb 7, 2021
b6a375c
Fix row indexing.
tsalo Feb 7, 2021
06bd83f
Fix suffix.
tsalo Feb 7, 2021
de0526f
Simplify handling of component indices.
tsalo Feb 7, 2021
b5b69a1
Fix.
tsalo Feb 7, 2021
840b1c0
Fix the reports.
tsalo Feb 7, 2021
7e70a7b
Fix the bugs.
tsalo Feb 7, 2021
860bff3
Fix more bugs.
tsalo Feb 9, 2021
e587849
Fix everything!
tsalo Feb 9, 2021
bb15c2e
Fix the loading?
tsalo Feb 9, 2021
4303b97
Update fiu_four_echo_outputs.txt
tsalo Feb 9, 2021
1aa52bc
Fix outputs!
tsalo Feb 9, 2021
2b1524f
Ugh...
tsalo Feb 10, 2021
6b4ab31
Add dataset_description.json.
tsalo Feb 10, 2021
ed45069
Update outputs and workflow description.
tsalo Feb 10, 2021
f7a4103
Fix output list.
tsalo Feb 10, 2021
fb7e8f8
Fix more outputs.
tsalo Feb 10, 2021
39a18f7
Remove unused functions.
tsalo Feb 10, 2021
245c7bd
Fix imports.
tsalo Feb 10, 2021
ed85699
Change desc-ICA to desc-tedana.
tsalo Feb 12, 2021
cd1ce51
Update docs.
tsalo Feb 12, 2021
cc9296b
Update docs/outputs.rst
tsalo Feb 23, 2021
0789f81
Merge pull request #574 from tsalo/ref/filenames-and-variables
tsalo Feb 24, 2021
2b9a7ab
[REF] Modularize io (#692)
jbteves Apr 1, 2021
adebb32
Merge branch 'main' into bids-derivatives
tsalo Apr 1, 2021
c10505b
Revert accidental changes to cornell_three_echo test results
Apr 2, 2021
7c947b2
Actually revert those changes
Apr 2, 2021
aa499b5
Use class for managing outputs (#711)
tsalo May 4, 2021
713a076
Remove constants.py
May 5, 2021
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
Prev Previous commit
Next Next commit
Merge branch 'master' into ref/filenames-and-variables
  • Loading branch information
tsalo committed Oct 22, 2020
commit eb23f74b332dc3f001afc11b82d285f1f49b2ac7
53 changes: 15 additions & 38 deletions tedana/gscontrol.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
import os.path as op

import numpy as np
from numpy.linalg import lstsq
import pandas as pd
from scipy import stats
from scipy.special import lpmv
@@ -219,37 +218,22 @@ def minimum_image_regression(optcom_ts, mmix, mask, comptable, ref_img, out_dir=
mehk_ts = np.dot(comp_pes[:, acc], mmix[:, acc].T)
t1_map = mehk_ts.min(axis=-1) # map of T1-like effect
t1_map -= t1_map.mean()
io.filewrite(
utils.unmask(t1_map, mask),
op.join(out_dir, 'desc-optcomAccepted_min.nii.gz'),
ref_img
)
io.filewrite(utils.unmask(t1_map, mask), op.join(out_dir, "desc-optcomAccepted_min"), ref_img)
t1_map = t1_map[:, np.newaxis]

# Find the global signal based on the T1-like effect
glob_sig = np.linalg.lstsq(t1_map, optcom_z, rcond=None)[0]

"""
T1-correct time series by regression
"""
bold_noT1gs = bold_ts - np.dot(lstsq(glob_sig.T, bold_ts.T,
rcond=None)[0].T, glob_sig)
hik_ts = bold_noT1gs * optcom_std
io.filewrite(
utils.unmask(hik_ts, mask),
op.join(out_dir, 'desc-optcomAcceptedT1cDenoised_bold.nii.gz'),
ref_img
# Remove T1-like global signal from MEHK time series
mehk_noT1gs = mehk_ts - np.dot(
np.linalg.lstsq(glob_sig.T, mehk_ts.T, rcond=None)[0].T, glob_sig
)
hik_ts = mehk_noT1gs * optcom_std # rescale
io.filewrite(utils.unmask(hik_ts, mask), op.join(out_dir, "desc-optcomAcceptedMIRDenoised_bold.nii.gz"), ref_img)

"""
Make denoised version of T1-corrected time series
"""
medn_ts = optcom_mu + ((bold_noT1gs + resid) * optcom_std)
io.filewrite(
utils.unmask(medn_ts, mask),
op.join(out_dir, 'desc-optcomT1cDenoised_bold.nii.gz'),
ref_img
)
# Make denoised version of T1-corrected time series
medn_ts = optcom_mean + ((mehk_noT1gs + resid) * optcom_std)
io.filewrite(utils.unmask(medn_ts, mask), op.join(out_dir, "desc-optcomMIRDenoised_bold.nii.gz"), ref_img)

# Orthogonalize mixing matrix w.r.t. T1-GS
mmix_noT1gs = mmix.T - np.dot(
@@ -260,18 +244,11 @@ def minimum_image_regression(optcom_ts, mmix, mask, comptable, ref_img, out_dir=
(np.atleast_2d(np.ones(max(glob_sig.shape))), glob_sig, mmix_noT1gs_z)
)

"""
Write T1-GS corrected components and mixing matrix
"""
cbetas_norm = lstsq(mmixnogs_norm.T, data_norm.T, rcond=None)[0].T
# Write T1-corrected components and mixing matrix
comp_pes_norm = np.linalg.lstsq(mmix_noT1gs_z.T, optcom_z.T, rcond=None)[0].T
io.filewrite(
utils.unmask(cbetas_norm[:, 2:], mask),
op.join(out_dir, 'desc-ICAAcceptedT1cDenoised_components.nii.gz'),
ref_img
utils.unmask(comp_pes_norm[:, 2:], mask),
op.join(out_dir, "desc-ICAAcceptedMIRDenoised_components.nii.gz"),
ref_img,
)
comp_names = [io.add_decomp_prefix(comp, prefix='ica',
max_value=comptable.index.max())
for comp in comptable.index.values]
mixing_df = pd.DataFrame(data=mmixnogs.T, columns=comp_names)
mixing_df.to_csv(op.join(out_dir, 'desc-ICAT1cDenoised_mixing.tsv'),
sep='\t', index=False)
np.savetxt(op.join(out_dir, "desc-ICAMIRDenoised_mixing.tsv"), mmix_noT1gs)
8 changes: 4 additions & 4 deletions tedana/tests/data/fiu_four_echo_outputs.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
S0map.nii.gz
T1gs.nii.gz
T2starmap.nii.gz
desc-ICAAcceptedT1cDenoised_components.nii.gz
desc-ICAAcceptedMIRDenoised_components.nii.gz
desc-ICAAveragingWeights_X.nii.gz
desc-ICAR2ModelPredictions_X.nii.gz
desc-ICAS0ModelPredictions_X.nii.gz
desc-ICAT1cDenoised_mixing.tsv
desc-ICAMIRDenoised_mixing.tsv
desc-ICAZ_components.nii.gz
desc-ICA_components.nii.gz
desc-ICA_decomposition.json
@@ -20,13 +20,13 @@ desc-adaptiveGoodSignal_mask.nii.gz
desc-full_S0map.nii.gz
desc-full_T2starmap.nii.gz
desc-globalSignal_regressors.tsv
desc-optcomAcceptedT1cDenoised_bold.nii.gz
desc-optcomAcceptedMIRDenoised_bold.nii.gz
desc-optcomAccepted_min.nii.gz
desc-optcomDenoised_bold.nii.gz
desc-optcomNoGlobalSignal_bold.nii.gz
desc-optcomPCAReduced_bold.nii.gz
desc-optcomRejected_bold.nii.gz
desc-optcomT1cDenoised_bold.nii.gz
desc-optcomMIRDenoised_bold.nii.gz
desc-optcomWithGlobalSignal_bold.nii.gz
desc-optcom_bold.nii.gz
echo-1_desc-Denoised_bold.nii.gz
You are viewing a condensed version of this merge commit. You can view the full changes here.