[ENH]: Add TemporalSlicer #443
No reviewers
Labels
No labels
CRITICAL
Stale
WIP
bug
concept
coordinate
dataset
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
maintenance
maps
marker
mask
on hold
parcellation
preprocess
question
ready
storage
template-space
triage
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
juaml/junifer!443
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/temporal-slicer-preproc"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Are you requiring a new dataset or marker?
Which feature do you want to include?
To have the option to define which segment of the time series to use for extracting connectomes (define start and end point). For example, cut a 20-minute sequence after 10 minutes and extract connectomes from only the second part.
Use-Case: We have a 24 minute sequence with a task and a control task performed sequentially and want to analyze them separately.
How do you imagine this integrated in junifer?
Cut the time series before calculating the connectomes.
Do you have a sample code that implements this outside of junifer?
Anything else to say?
@kaurao
@jkroell Hi! Thanks for the feature request. Not sure I understand it correctly, do you want an option to perform temporal slicing at the marker level or do you want a preprocessor?
I think this can be implemented at different levels, either in preprocessing or in the marker. I guess making it part of preprocessing with make it more general and applicable across different markers?
@kaurao Ok then we go with a new preprocessor.
Codecov Report
Attention: Patch coverage is
98.41270%with1 linein your changes missing coverage. Please review.Additional details and impacted files
100.00% <ø> (ø)91.09% <98.41%> (+4.96%)Flags with carried forward coverage won't be shown. Click here to find out more.
94.64% <ø> (ø)98.41% <98.41%> (ø)... and 26 files with indirect coverage changes
🚀 New features to boost your workflow:
@jkroell How do you like this interface?
@synchon @kaurao @jkroell Does it make sense to add the positibility to specify intervals in several ways?
[tstart, tend][tstart, tstart+len]Ej:
tstart=0, len=10*60tstart=10*60, tend=20*60start and stop, if in seconds, should be floats. If we have sub-second TR we are in trouble. We'll most probably have rounding errors.
Adding a
lendoesn't make sense to me as you can calculate that and be sure of yourtenddepending ont_r. But maybe, as an end-user, Jean's thoughts might differ.Why can't we support both?
It's easier to copy/paste a yaml and then change the tstart if you want to analyse 10 minutes from T0 and 10 minutes from T1, where T1 is a number that we know from the acquisition.
Making them floats is a good idea to be more precise with slicing. I anyway do an int conversion to take care of that, most you get is an IndexError.
Of course we can, not a problem. Just wanted to make sure there's a proper use case.
This is taken care of now.
If we can do the math for the user, better.
I had this use case recently because someone merged resting with a task so I had to discard some volumes at the begining. Which also makes me think that in that case I needed:
tend=Noneandlen=Noneshould mean until the end of the recording.Another possible use case:
tend<0could also mean stop endtendseconds from the end. Basically, croptendseconds from the end.https://juaml.github.io/junifer/pr-preview/pr-443/
Built to branch
gh-pagesat 2025-04-08 14:49 UTC.Preview will be ready when the GitHub Pages deployment is complete.
I like the interface! Would it be an option to automatically get the TR, or do you think the user should set that himself?
If the TR is not specified, it will be taken from the images. However, keep in mind that some software do not take care of the TR properly, so it's always good to have an option to fix it manually.
Okay, makes sense! Looks good to me, then.
@jkroell Was about to reply, but Fede already gave a nice answer.
@fraimondo Have added support for negative indexing in
stop.@fraimondo Ok so now we can have
stop=Nonewhich would take you to end anddurationwhich is added tostartto address the situations you described. I believe it's better to adjust the confounds as well?The interface now looks like:
stop:Does it make sense now? @fraimondo @jkroell @kaurao
Yes! Perfect sense.
And you are right, we need to adjust the confounds so they match. Though I believe this should be used after confound removal.
Ideally it should be after confound removal, but is there a case where one can do it before confound removal or can use the confounds in markers?
We need to be consistent. So I agree with you. Any picking on the BOLD timeseries should also pick any other data that matches.
Okay then I'll make the necessary changes.
@fraimondo Updated the code to reflect confounds manipulation, I'll request a review, feel free to add more comments before reviewing.
@ -0,0 +177,4 @@# Convert slice range from seconds to indicesindex = slice(int(self.start // t_r), int(stop // t_r))Can we thorugh out of bounds exceptions ourselves?
Maybe also an INFO log to show the user what's being "sliced".
@ -0,0 +177,4 @@# Convert slice range from seconds to indicesindex = slice(int(self.start // t_r), int(stop // t_r))@fraimondo The new commits should address your comments, feel free to add an approval if you are ok with the PR.
@fraimondo Shall we get this in?
Using the slicer after confound removal worked successfully. Thanks for adding this!