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

Remove accepted and rejected time series from the standard file outputs and change denoised time series name (updated) #1033

Merged
merged 16 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
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
48 changes: 31 additions & 17 deletions tedana/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ def write_split_ts(data, mmix, mask, comptable, io_generator, echo=0):
Output directory.
echo : :obj: `int`, optional
Echo number to generate filenames, used by some verbose
functions. Default 0.
functions. Currently this is only not 0 when
io_generator.verbose==True. Default 0.

Returns
-------
Expand All @@ -562,13 +563,23 @@ def write_split_ts(data, mmix, mask, comptable, io_generator, echo=0):
Generated Files
---------------

============================ ============================================
Filename Content
============================ ============================================
[prefix]Accepted_bold.nii.gz High-Kappa time series.
[prefix]Rejected_bold.nii.gz Low-Kappa time series.
[prefix]Denoised_bold.nii.gz Denoised time series.
============================ ============================================
===================================== ============================================
Filename Content
===================================== ============================================
desc-optcomDenoised_bold.nii.gz Denoised time series.

if io_generator.verbose==True
desc-optcomAccepted_bold.nii.gz High-Kappa time series.
desc-optcomRejected_bold.nii.gz Low-Kappa time series.

if echo>0
echo-[echo]_desc-Accepted_bold.nii.gz High-Kappa timeseries for echo
number ``echo``.
echo-[echo]_desc-Rejected_bold.nii.gz Low-Kappa timeseries for echo
number ``echo``.
echo-[echo]_desc-Denoised_bold.nii.gz Denoised timeseries for echo
number ``echo``.
===================================== ============================================
"""
acc = comptable[comptable.classification == "accepted"].index.values
rej = comptable[comptable.classification == "rejected"].index.values
Expand All @@ -578,16 +589,18 @@ def write_split_ts(data, mmix, mask, comptable, io_generator, echo=0):
if len(acc) != 0:
if echo != 0:
fout = io_generator.save_file(hikts, "high kappa ts split img", echo=echo)
else:
LGR.info(f"Writing high-Kappa time series: {fout}")
elif io_generator.verbose:
fout = io_generator.save_file(hikts, "high kappa ts img")
LGR.info(f"Writing high-Kappa time series: {fout}")
LGR.info(f"Writing high-Kappa time series: {fout}")
tsalo marked this conversation as resolved.
Show resolved Hide resolved

if len(rej) != 0:
if echo != 0:
fout = io_generator.save_file(lowkts, "low kappa ts split img", echo=echo)
else:
LGR.info(f"Writing low-Kappa time series: {fout}")
elif io_generator.verbose:
fout = io_generator.save_file(lowkts, "low kappa ts img")
LGR.info(f"Writing low-Kappa time series: {fout}")
LGR.info(f"Writing low-Kappa time series: {fout}")
tsalo marked this conversation as resolved.
Show resolved Hide resolved

if echo != 0:
fout = io_generator.save_file(dnts, "denoised ts split img", echo=echo)
Expand Down Expand Up @@ -623,19 +636,20 @@ def writeresults(ts, mask, comptable, mmix, io_generator):
Generated Files
---------------

========================================= =====================================
========================================= ===========================================
Filename Content
========================================= =====================================
desc-optcomAccepted_bold.nii.gz High-Kappa time series.
desc-optcomRejected_bold.nii.gz Low-Kappa time series.
========================================= ===========================================
desc-optcomDenoised_bold.nii.gz Denoised time series.
handwerkerd marked this conversation as resolved.
Show resolved Hide resolved

desc-optcomAccepted_bold.nii.gz High-Kappa time series. (only with verbose)
desc-optcomRejected_bold.nii.gz Low-Kappa time series. (only with verbose)
desc-ICA_components.nii.gz Spatial component maps for all
components.
desc-ICAAccepted_components.nii.gz Spatial component maps for accepted
components.
desc-ICAAccepted_stat-z_components.nii.gz Z-normalized spatial component maps
for accepted components.
========================================= =====================================
========================================= ===========================================
"""
acc = comptable[comptable.classification == "accepted"].index.values
write_split_ts(ts, mmix, mask, comptable, io_generator)
Expand Down
2 changes: 1 addition & 1 deletion tedana/resources/config/outputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"denoised ts img": {
"orig": "dn_ts_OC",
"bidsv1.5.0": "desc-optcomDenoised_bold"
"bidsv1.5.0": "desc-denoised_bold"
},
"high kappa ts img": {
"orig": "hik_ts_OC",
Expand Down
4 changes: 1 addition & 3 deletions tedana/tests/data/cornell_three_echo_outputs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ desc-PCA_metrics.tsv
desc-PCA_mixing.tsv
desc-PCA_stat-z_components.nii.gz
desc-adaptiveGoodSignal_mask.nii.gz
desc-optcomAccepted_bold.nii.gz
desc-optcomDenoised_bold.nii.gz
desc-optcomRejected_bold.nii.gz
desc-denoised_bold.nii.gz
desc-optcom_bold.nii.gz
figures
figures/carpet_optcom.svg
Expand Down
2 changes: 1 addition & 1 deletion tedana/tests/data/fiu_four_echo_outputs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sub-01_desc-limited_S0map.nii.gz
sub-01_desc-limited_T2starmap.nii.gz
sub-01_desc-optcomAcceptedMIRDenoised_bold.nii.gz
sub-01_desc-optcomAccepted_bold.nii.gz
sub-01_desc-optcomDenoised_bold.nii.gz
sub-01_desc-denoised_bold.nii.gz
sub-01_desc-optcomMIRDenoised_bold.nii.gz
sub-01_desc-optcomNoGlobalSignal_bold.nii.gz
sub-01_desc-optcomRejected_bold.nii.gz
Expand Down
2 changes: 1 addition & 1 deletion tedana/tests/data/nih_five_echo_outputs_verbose.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sub-01_desc-adaptiveGoodSignal_mask.nii.gz
sub-01_desc-limited_S0map.nii.gz
sub-01_desc-limited_T2starmap.nii.gz
sub-01_desc-optcomAccepted_bold.nii.gz
sub-01_desc-optcomDenoised_bold.nii.gz
sub-01_desc-denoised_bold.nii.gz
sub-01_desc-optcom_whitened_bold.nii.gz
sub-01_desc-optcomRejected_bold.nii.gz
sub-01_desc-optcom_bold.nii.gz
Expand Down
2 changes: 0 additions & 2 deletions tedana/tests/data/reclassify_debug_out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sub-testymctestface_dataset_description.json
sub-testymctestface_dn_ts_OC.nii.gz
sub-testymctestface_dn_ts_OC_MIR.nii.gz
sub-testymctestface_feats_OC2.nii.gz
sub-testymctestface_hik_ts_OC.nii.gz
sub-testymctestface_hik_ts_OC_MIR.nii.gz
sub-testymctestface_ica_components.nii.gz
sub-testymctestface_ica_cross_component_metrics.json
Expand All @@ -21,6 +20,5 @@ sub-testymctestface_ica_mir_mixing.tsv
sub-testymctestface_ica_mixing.tsv
sub-testymctestface_ica_orth_mixing.tsv
sub-testymctestface_ica_status_table.tsv
sub-testymctestface_lowk_ts_OC.nii.gz
sub-testymctestface_registry.json
sub-testymctestface_sphis_hik.nii.gz
3 changes: 1 addition & 2 deletions tedana/tests/data/reclassify_no_bold.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ desc-ICA_decomposition.json
desc-ICA_mixing.tsv
desc-ICA_stat-z_components.nii.gz
desc-ICA_status_table.tsv
desc-optcomDenoised_bold.nii.gz
desc-optcomRejected_bold.nii.gz
desc-denoised_bold.nii.gz
desc-tedana_metrics.json
desc-tedana_metrics.tsv
desc-tedana_registry.json
Expand Down
4 changes: 1 addition & 3 deletions tedana/tests/data/reclassify_quiet_out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ desc-ICA_decomposition.json
desc-ICA_mixing.tsv
desc-ICA_stat-z_components.nii.gz
desc-ICA_status_table.tsv
desc-optcomAccepted_bold.nii.gz
desc-optcomDenoised_bold.nii.gz
desc-optcomRejected_bold.nii.gz
desc-denoised_bold.nii.gz
desc-tedana_metrics.json
desc-tedana_metrics.tsv
desc-tedana_registry.json
Expand Down
4 changes: 1 addition & 3 deletions tedana/tests/data/reclassify_run_twice.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ desc-ICA_decomposition.json
desc-ICA_mixing.tsv
desc-ICA_stat-z_components.nii.gz
desc-ICA_status_table.tsv
desc-optcomAccepted_bold.nii.gz
desc-optcomDenoised_bold.nii.gz
desc-optcomRejected_bold.nii.gz
desc-denoised_bold.nii.gz
desc-tedana_metrics.json
desc-tedana_metrics.tsv
desc-tedana_registry.json
Expand Down
12 changes: 12 additions & 0 deletions tedana/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def test_smoke_write_split_ts():
classification = np.random.choice(["accepted", "rejected", "ignored"], n_components)
df_data = np.column_stack((component, metric, classification))
comptable = pd.DataFrame(df_data, columns=["component", "metric", "classification"])
io_generator.verbose = True

me.write_split_ts(data, mmix, mask, comptable, io_generator)

Expand All @@ -153,6 +154,17 @@ def test_smoke_write_split_ts():
# remove all files generated
os.remove(filename)

io_generator.verbose = False

me.write_split_ts(data, mmix, mask, comptable, io_generator)

# TODO: midk_ts.nii is never generated?
fn = io_generator.get_name
split = "denoised ts img"
fname = fn(split)
# remove all files generated
os.remove(fname)


def test_smoke_filewrite():
"""
Expand Down