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

Conversation

tsalo
Copy link
Member

@tsalo tsalo commented Feb 24, 2021

Closes #146 and closes #649.

Changes proposed in this pull request:

  • Rename outputs to be as BIDS Derivatives-compatible as possible.
  • Reorganize metric and decomposition files. Metrics are now stored in TSVs, with associated JSONs describing the metrics, and decomposition files should match BEP012 convention.

@tsalo
Copy link
Member Author

tsalo commented Apr 2, 2021

I'm still wary of global variables, so I was thinking that a new OutputGenerator class could do the same work by storing ref_img, out_dir, prefix, convention, and the loaded config dictionaries (stored as jsons, as currently implemented) as attributes. Since we're already passing around ref_img, this would keep the number of arguments to most of the functions the same as they are now. I've started mocking something up that I can proposed in a PR to this branch, but I thought I'd bring up the idea here first.

EDIT: Here is the current, not-yet-functional idea.

@jbteves
Copy link
Collaborator

jbteves commented Apr 2, 2021

That seems fine to me. Then if we want to add outputs (for example, writing metrics to .csv formats) it's pretty straightforward to add it to that class. I'd debated a similar solution but historically we've avoided object-oriented solutions to problems so I thought my procedural implementation would be more suitable.

I'm not particularly scared of global variables in this context because they're truly global, though, and then this output generator will also effectively be a global variable.

I'd be curious to hear what @emdupre and @handwerkerd think.

@handwerkerd
Copy link
Member

I just skimmed @tsalo's OutputGenerator and it looks conceptually fine. I'm also fine with the currently proposed globals. The one advantage I see with OutputGenerator is, if there is a creep towards creating more globally customizable options (i.e. svg & png options), this will keep these options in a more coherent and structured place.

@emdupre
Copy link
Member

emdupre commented Apr 6, 2021

Just a +1 from me for the class-based approach, here.

You're definitely right @jbteves that we've generally avoided classes, and I at least can confess to being wary of bringing them in prematurely (having seen how quickly they can grow in complexity). But in this case I think a class has the dual benefit of being a bit easier to conceptually track in the long run (!), and putting us on a firm footing away from global-scope-creep.

@jbteves
Copy link
Collaborator

jbteves commented Apr 6, 2021

I'm on board with moving to a class-based approach if everyone else is, then. It's certainly more elegant than what I merged into here 🙂. That said, I wonder if we should open an issue to discuss/specify the full interface since it would be a paradigm shift. I also wonder if we should go ahead and merge this as something of a temporary fix while we hash out the details? The output generator class opens up quite a few possibilities for how we handle output, and this set of changes is relatively contained (though I admit I introduced quite a bit of scope creep already 😬): it focuses exclusively on images and metric data/metadata. Right now, the report and figure generation is completely out of the scope of this PR even with my changes, but a full OutputGenerator would handle those as well, I assume. It would also presumably fill in the dataset description, which requires more file-tracking. It could be a very large set of changes at the end. Thoughts?

@handwerkerd
Copy link
Member

I'm fine if someone opens an issue to expand the discussion on an overall structure for I/O and UI. Even if having a coherent plan for UI & I/O may be a bit premature, having a place for the discussion might guide some decisions. That said, I think we have a fairly clear path forward for this PR. I wouldn't want that discussion to hold up finishing and merging this PR.

@handwerkerd handwerkerd added breaking change WIll make a non-trivial change to outputs and removed output-change labels Apr 16, 2021
@tsalo
Copy link
Member Author

tsalo commented Apr 19, 2021

I was able to make progress on #711 this past weekend, but I wasn't able to get it ready for review. As such, I'm happy to move forward with this PR as-is (after we address #718 and #721 and release 0.0.10, of course), and then merge #711 into main instead. @jbteves if you have the time and interest to tackle #711, I would appreciate the help. If not, then no pressure!

@jbteves
Copy link
Collaborator

jbteves commented Apr 19, 2021

Sorry, to clarify, the order you'd like is:

  1. Merge [DOC] Add warning about not using release-drafter releases to developer instructions #718, [MAINT] Drop 3.5 support and begin 3.8 and 3.9 support #721
  2. Release 0.0.10
  3. Merge Use class for managing outputs #711 into this
  4. Merge this to main

?

RE: working on #711, sure, I can take that over for you this week. I'm taking a short week though so I may not report further on progress until early next week instead.

@tsalo
Copy link
Member Author

tsalo commented Apr 19, 2021

If I had gotten #711 ready in time, then that's the order I would have preferred. Since it's not ready, though, I'm happy with:

  1. Merge [DOC] Add warning about not using release-drafter releases to developer instructions #718, [MAINT] Drop 3.5 support and begin 3.8 and 3.9 support #721
  2. Release 0.0.10
  3. Merge this into main
  4. Merge Use class for managing outputs #711 into main

It really depends on how fast we can get the necessary reviews for #718 and #721, and when we'll be able to get #711 ready (which may depend on how much time you have for it).

@jbteves
Copy link
Collaborator

jbteves commented Apr 19, 2021

Alright, that makes sense. Thanks for the clarification. Could we mark this as ready for review, review it, and then plan on merging in #711 if it's finished by next Friday, or else just going ahead and merging this, and then retargeting #711 to main? That seems like a pretty decent timeline for me.

@tsalo tsalo marked this pull request as ready for review April 19, 2021 21:37
* Initial work on a class.

* Clean up.

* More work.

* Revert mistake.

* [FIX] Adds f_max to right place (#712)

Moves f_max thresholding to the step where the R2/S0 maps are written out, rather than just before kappa/rho calculation.

* [FIX] Calculate Kappa and Rho on full F-statistic maps (#714)

* Calculate rho and kappa on full maps.

* Add missing test outputs.

* Revert changes to outputs.

* Fill out docstrings for file-writing class.

* More work.

* [MAINT] Drop 3.5 support and begin 3.8 and 3.9 support (#721)

* Drop 3.5 support and add 3.8/3.9 support.

* Drop 3.5 tests and add 3.8/3.9 tests.

* Update installation instructions.

* Progress on refactor

* Fix some errors

* Fix style

* Switch to fstrings where possible

* Update tedana/io.py

Co-authored-by: Taylor Salo <tsalo006@fiu.edu>

* Update tedana/io.py

Co-authored-by: Taylor Salo <tsalo006@fiu.edu>

* Address @handwerkerd docstring review

* Replace generator with io_generator

Co-authored-by: Joshua Teves <jbtevespro@gmail.com>
Co-authored-by: Joshua Teves <joshua.teves@nih.gov>
jbteves
jbteves previously approved these changes May 4, 2021
@jbteves jbteves requested a review from handwerkerd May 4, 2021 17:09
Copy link
Member

@handwerkerd handwerkerd left a comment

Choose a reason for hiding this comment

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

Is constants.py no longer used? I think it's a vestige from before we switched to the class structure.

@jbteves jbteves requested a review from handwerkerd May 5, 2021 17:16
@jbteves
Copy link
Collaborator

jbteves commented May 5, 2021

@tsalo just want your confirmation before I merge this behemoth.

@tsalo
Copy link
Member Author

tsalo commented May 5, 2021

Thanks for the heads up. Since we just made a release, I don't think we're under any pressure to release anything immediately after merging this, so I'm happy to see this merged today, and then we can triple check everything before 0.0.11 (or 0.1.0, depending on how we feel).

@jbteves jbteves merged commit ad664ae into main May 5, 2021
@jbteves jbteves deleted the bids-derivatives branch May 5, 2021 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change WIll make a non-trivial change to outputs effort: high More than 40h total work impact: medium Improves code/documentation functionality for some users priority: high issues that would be really helpful if they were fixed already
Projects
None yet
4 participants