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] Make outputs BIDS derivatives-compatible #152

Closed
wants to merge 59 commits into from

Conversation

tsalo
Copy link
Member

@tsalo tsalo commented Nov 1, 2018

Closes #146, closes #180, and closes #252.

We should wait until #136 is merged to deal with this PR, as this will involve editing every function that generates files.

Changes proposed in this pull request:

  • Add function gen_fname to generate BIDS derivatives-compatible filenames from a base file (input file corresponding to first echo), a description for the output file, the data type, and the file extension.
  • Replace argument label with out_dir in workflows.
  • Add bf (base filename) argument to all file-generating functions.
  • Get automatic gzipping working in filewrite.
  • Remove unused ctabsel function.

@tsalo tsalo added the enhancement issues describing possible enhancements to the project label Nov 2, 2018
@codecov
Copy link

codecov bot commented Nov 2, 2018

Codecov Report

Merging #152 into master will decrease coverage by 0.75%.
The diff coverage is 26.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
- Coverage   46.11%   45.35%   -0.76%     
==========================================
  Files          33       33              
  Lines        2045     2154     +109     
==========================================
+ Hits          943      977      +34     
- Misses       1102     1177      +75
Impacted Files Coverage Δ
tedana/workflows/tedana.py 13.29% <0%> (-1.36%) ⬇️
tedana/tests/test_io.py 100% <100%> (ø) ⬆️
tedana/tests/test_model_fit_fitmodels_direct.py 100% <100%> (ø) ⬆️
tedana/tests/test_gscontrol.py 100% <100%> (ø) ⬆️
tedana/workflows/t2smap.py 67.1% <100%> (ø) ⬆️
tedana/tests/test_utils.py 100% <100%> (ø) ⬆️
tedana/model/fit.py 29.41% <12.5%> (-1.03%) ⬇️
tedana/gscontrol.py 22.53% <20%> (ø) ⬆️
tedana/io.py 41.76% <31.25%> (-6.11%) ⬇️
tedana/decomposition/eigendecomp.py 10.61% <4.76%> (+0.14%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82447c5...d367280. Read the comment docs.

tsalo added 9 commits November 2, 2018 17:51
Now it can take in any number of keyword arguments to be added as
fields in the filename.
Also rename generate_fname to gen_fname.

# Conflicts:
#	tedana/tests/test_utils.py
#	tedana/workflows/tedana.py
I realized that not every derivative would be a “bold” file.
@tsalo tsalo removed the enhancement issues describing possible enhancements to the project label Nov 11, 2018
@emdupre emdupre mentioned this pull request Nov 27, 2018
2 tasks
# Conflicts:
#	tedana/selection/select_comps.py
tedana/io.py Show resolved Hide resolved
# Conflicts:
#	tedana/workflows/tedana.py
Updates to gen_fname:
- Remove duplicate keys (e.g., “desc”) when adding keys to filename.
- Use basefile’s directory (without editing).
- Add echo as first key in output filename if provided.

Other updates:
- Use outdir in basefile to eliminate need for out_dir argument in all
file writing functions.
- Update filenames to match proposed conventions.
- Add bf argument to tedpca, gscontrol_mmix, write_split_ts,
writefeats, writeresults, writeresults_echoes, and gscontrol_raw to
call gen_fname within these functions.
- Get automatic gzipping working in filewrite.
- Delete unused ctabsel.

Still need to update function docstrings with updated arguments and
write out metadata (jsons). Also maybe some record of the arguments
used.
@tsalo tsalo changed the title [WIP, ENH] Make outputs BIDS derivatives-compatible [ENH] Make outputs BIDS derivatives-compatible Jan 5, 2019
@tsalo
Copy link
Member Author

tsalo commented Mar 21, 2019

Tests are now passing and figures are outputted in BIDS format. The names may need to be adjusted, but everything generally looks good to me. This is ready for review.

tsalo added 3 commits March 22, 2019 14:47
# Conflicts:
#	tedana/decomposition/eigendecomp.py
#	tedana/io.py
#	tedana/model/fit.py
#	tedana/tests/test_gscontrol.py
#	tedana/workflows/tedana.py
Copy link
Member

@emdupre emdupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge improvement, thank you !!! I've left a few comments.

One very general thought: we also need to be writing out a _decomposition.json with our mixing matrices, see here.

docs/outputs.rst Outdated
======================================== =====================================================
Filename Content
======================================== =====================================================
*_desc-limited_t2s.nii.gz Limited estimated T2* 3D map.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please ! Let's update for T2Starmap and S0map.

docs/outputs.rst Outdated Show resolved Hide resolved
docs/outputs.rst Outdated
of echoes, starting with 2.
*_desc-ascendingEstimates_s0.nii.gz Voxel-wise S0 estimates using ascending numbers
of echoes, starting with 2.
*_desc-full_t2s.nii.gz Full T2* map/time series. The difference between
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just get rid of this desc. It should be clear that it's "full" in comparison to the desc-limited files above !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only don't like this because full is only used for optimal combination. It contains T2* estimates for voxels with only one good echo, which in my mind makes it less of a "full" map and more of a... liberal map? I'm not sure what to call it, but I think we should rename it. What about changing limited to nothing (dropping desc) and changing full to liberal?

docs/outputs.rst Outdated
good data, the full map uses the single echo's
value while the limited map has a NaN. Only used
for optimal combination.
*_desc-full_s0.nii.gz Full S0 map/time series. Only used for optimal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment on dropping this desc key-value pair !

*_desc-T1gs_bold.nii.gz Spatial global signal
*_globalSignal_regressors.tsv Time series of global signal from optimally combined
data.
*_desc-optcomWithGlobalSignal_bold.nii.gz Optimally combined time series with global signal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already covered on L22 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gsr method outputs two files that contain the same contents, I guess, although I think the duplicate is actually *_desc-optcomNoGlobalSignal_bold.nii.gz.

================================================== =====================================================
Filename Content
================================================== =====================================================
*_desc-optcomAccepted_min.nii.gz T1-like effect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we comment on the derivs PR to suggest it ?

@@ -185,6 +185,8 @@ def tedpca(catd, OCcatd, combmode, mask, t2s, t2sG,
Boolean mask array
ref_img : :obj:`str` or img_like
Reference image to dictate how outputs are saved to disk
bf : :obj:`str`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to something a little more intuitive ? You mean everything before like echo- in the original filename, right ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That part of the filename and the output directory as well. Do you have a preference for the new name? bf stands for base filename, so that's a possibility.

@emdupre
Copy link
Member

emdupre commented Mar 24, 2019

I think there are a few general discussion points that we might want to rope in others for, as they extend more broadly into BIDS. In particular, there are two immediate things I can think of that will make our file names much more intuitive.

  1. Moving optcomb out of desc. It would be great if instead we could denote this under the echo key, with something like echo-combined or echo-all. This actually might be something that BEP001 folks already have ideas about (@KirstieJane @handwerkerd ?).

  2. Moving accepted/rejected/ignored classifications out of desc. I know AROMA shares this problem, and @effigies has already thought about it in that context. It won't make it into the current derivs PR, but we could trial our own a solution here !

@tsalo
Copy link
Member Author

tsalo commented Mar 24, 2019

@emdupre I've added the decomposition files now. Please let me know what you think of them from the integration test artifacts.

tsalo added 8 commits March 30, 2019 12:22
Also fix up docstrings and eliminate step where component number is set
as a column. Always keep it as the index of the DataFrame.
* Speed up spatclust function.

This also clusters positive and negative values separately.

* Rename spatclust to threshold_map and add binarize/sided arguments.

* Replace manually generated binary structure with function-made one.
# Conflicts:
#	tedana/model/__init__.py
#	tedana/model/fit.py
#	tedana/selection/select_comps.py
#	tedana/workflows/tedana.py
tsalo added 2 commits April 3, 2019 12:01
# Conflicts:
#	tedana/decomposition/eigendecomp.py
#	tedana/io.py
#	tedana/model/fit.py
#	tedana/viz.py
#	tedana/workflows/tedana.py
@jbteves
Copy link
Collaborator

jbteves commented Apr 19, 2019

@tsalo and @emdupre is this a WIP? If so, could we update the tag? If not, is there anything I could help review on?

@jbteves
Copy link
Collaborator

jbteves commented May 23, 2019

@tsalo You may want to update this branch after the refactor.

@tsalo
Copy link
Member Author

tsalo commented May 23, 2019

@jbteves I'm planning to hold off on updating until we deal with #251, since that will also probably break things.

@tsalo
Copy link
Member Author

tsalo commented Sep 15, 2019

I'm going to close this. I'll probably circle back and take another crack at it at a later date.

@tsalo tsalo closed this Sep 15, 2019
@tsalo tsalo deleted the bids-derivatives branch May 1, 2020 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants