Implementing an iterative delay correction strategy to improve CVR estimation in clinical populations - #160
Implementing an iterative delay correction strategy to improve CVR estimation in clinical populations#160beccaclements99 wants to merge 8 commits into
Conversation
|
@beccaclements99 I saw that pre-commit didn't run properly - I would suggest you install it locally for it to run when you commit (see here). |
|
I also have a couple of initial questions for clarification:
|
| final_lag_idx : ndarray | ||
| Selected lag indices per voxel. | ||
| """ | ||
|
|
There was a problem hiding this comment.
The empty line will be flagged by Ruff
| lag = (lag_idx * step) / freq + (mask * lag_min) | ||
| else: | ||
| lag_idx = np.argmax(r_square_all, axis=-1) | ||
| lag = (lag_idx * step) / freq + (mask * lag_min) |
There was a problem hiding this comment.
| lag = (lag_idx * step) / freq + (mask * lag_min) | |
| else: | |
| lag_idx = np.argmax(r_square_all, axis=-1) | |
| lag = (lag_idx * step) / freq + (mask * lag_min) | |
| else: | |
| lag_idx = np.argmax(r_square_all, axis=-1) | |
| lag = (lag_idx * step) / freq + (mask * lag_min) |
Line 795 and 798 are the same, so we can just bring them out of the if statement ;)
| return final_lag_idx | ||
|
|
There was a problem hiding this comment.
| return final_lag_idx | |
| return final_lag_idx | |
Ruff will flag not having 2 empty lines
| final_max, | ||
| lag_min, | ||
| lag_step, | ||
| freq, |
There was a problem hiding this comment.
It doesn't look like you are using freq in the function - can you have another look at it please?
|
@beccaclements99 besides the couple of feedback points I already left, there are a couple of things that I'd like to discuss regarding the implementation - bearing in mind that we might have to modularise the workflow a bit more than previously planned.
Let me know what do you think and how I can be of help! |
This code implements the iterative delay correction approach described in this preprint. This approach is useful for clinical cohorts when the appropriate maximum shift is not known. We found that using a maximum shift that is too small can result in many delay estimates at the boundary (meaning that they are probably not optimized), but a conservatively large maximum shift can result in spurious negative CVR values. To address this, the delay search range is selectively expanded only for voxels with estimated delays at a boundary (i.e., within 1 lag step of the minimum or maximum shift) until the estimated delay is no longer at a boundary or a predefined value is reached.
Proposed Changes
- A starting_lag_max is provided and no lag_increment is specified
- A starting_lag_max is provided and it is greater than or equal to lag_max
- A lag map is provided AND starting_lag_max is specified. (The lag map option does not work with the iterative lag search)
Change Type
bugfix(+0.0.1)minor(+0.1.0)major(+1.0.0)refactoring(no version update)test(no version update)infrastructure(no version update)documentation(no version update)otherChecklist before review