Skip to content

Commit

Permalink
Remove accepted and rejected time series from the standard file outpu…
Browse files Browse the repository at this point in the history
…ts and change denoised time series name (updated) (#1033)

* Fix time series

* Fix elif

* Apply new names to integration test output

* Update io unit test

* Update test io

* Update input reclassify_quiet_out.txt

* Changes in reclassify

* Ran black

* Update in cornell_three_echo_outputs.txt

* updated documentation

* Apply suggestions from code review

doc correction

Co-authored-by: Taylor Salo <tsalo90@gmail.com>

* Added comment for confusing code section

---------

Co-authored-by: Marta Arbizu Gómez <127724722+martaarbizu@users.noreply.github.com>
Co-authored-by: Eneko Uruñuela <e.urunuela@icloud.com>
Co-authored-by: Taylor Salo <tsalo90@gmail.com>
  • Loading branch information
4 people authored Feb 20, 2024
1 parent 37bae3a commit 0d66342
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 34 deletions.
54 changes: 36 additions & 18 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-denoised_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 @@ -577,17 +588,23 @@ def write_split_ts(data, mmix, mask, comptable, io_generator, echo=0):

if len(acc) != 0:
if echo != 0:
# This outputs time series for a single echo
# In practice this only happens when verbose is true
# in io.writeresults_echoes. Neither this or the elif below
# are written out if verbose is not true
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}")

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}")

if echo != 0:
fout = io_generator.save_file(dnts, "denoised ts split img", echo=echo)
Expand Down Expand Up @@ -623,19 +640,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.
========================================= ===========================================
desc-denoised_bold.nii.gz Denoised time series.
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

0 comments on commit 0d66342

Please sign in to comment.