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

Add check_bbox argument management #641

Merged
merged 6 commits into from
Mar 7, 2023
Merged

Conversation

EmmaRenauld
Copy link
Contributor

Very small fix, remove bounding box valid checks.

AntoineTheb
AntoineTheb approved these changes Nov 3, 2022
Copy link
Contributor

@AntoineTheb AntoineTheb left a comment

Choose a reason for hiding this comment

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

Personnellement je mettrais ça partout dans scilpy, mais c'est en effet une bonne idée d'ajouter ça au moins au scoring.

@arnaudbore arnaudbore self-requested a review November 3, 2022 16:27
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Ok can you tell me a little bit about why this is such an issue ? Why we don't add a new arg to force bbox_valid_check to false ?

@EmmaRenauld
Copy link
Contributor Author

I'm not sure in other scripts, but here we are scoring tractograms that are potentially bad.

But if I try to think about general cases, I would say the most probable case is when vertical bundles/streamlines go too far in the brainstem under the pons, into the spinal cord, they can go out of the image quite easily. Other ideas, @AntoineTheb ?

@AntoineTheb
Copy link
Contributor

Yeah that's usually the problem. The FiberCup's ground truth also goes out its volume.

@AntoineTheb
Copy link
Contributor

Thinking about it, it could probably be a good idea to add an option to the argparser to disable bbox checking (and make it easily available to other scripts, like the --verbose or --force option for example). I'll add an issue to remind myself to do it @arnaudbore @EmmaRenauld .

@arnaudbore
Copy link
Contributor

I agree, I don't like to automatically skip the bbox checking.

@EmmaRenauld
Copy link
Contributor Author

I agree too.

@EmmaRenauld EmmaRenauld changed the title Fix: Add check_bbox_false to scil_score_bundles Add check_bbox argument management Nov 8, 2022
@EmmaRenauld
Copy link
Contributor Author

EmmaRenauld commented Nov 8, 2022

I made the change in all scripts using that check. Tested the whole pytest locally, it works.

During loading: when using load_tractogram_with_reference, you don't need to send the info, it will get it in bbox_check in the args, the same way as is done with the ref.

During saving: we use bbox_valid_check=args.bbox_check.

@AntoineTheb
Copy link
Contributor

Cool ! Do you have a tractogram to test it ?

@AntoineTheb AntoineTheb self-requested a review November 8, 2022 18:52
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

1 similar comment
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@EmmaRenauld
Copy link
Contributor Author

scoring_data=$BrainData/databases/ismrm_2015/derivatives/scoring_data/output/version_2022
ref=$scoring_data/t1.nii.gz
config_file_segmentation=$scoring_data/config_file_segmentation.json
config_file_tractometry=$scoring_data/config_file_tractometry.json
submissions_dir=$BrainData/databases/ismrm_2015/derivatives/submissions/output/anonymized_submissions_converted_tck

out_dir_root=tmp/
mkdir $out_dir_root

tractogram=$submissions_dir/3_3.tck
team=3_3
out_dir=$out_dir_root/$team;

# ------ Segmentation -------
scil_score_tractogram.py -f -v $tractogram $config_file_segmentation $out_dir --no_empty \
          --gt_dir $scoring_data --reference $ref --json_prefix tmp_  # ----------------> Fails

scil_score_tractogram.py -f -v $tractogram $config_file_segmentation $out_dir --no_empty \
          --gt_dir $scoring_data --reference $ref --json_prefix tmp_ --no_bbox_check  # --------> works

# ------ Final scoring -------
scil_score_bundles.py -f -v $config_file_tractometry $out_dir \
            --gt_dir $scoring_data --reference $ref;  # ----------------> Fails

scil_score_bundles.py -f -v $config_file_tractometry $out_dir \
            --gt_dir $scoring_data --reference $ref --bbox_check False;  # ------------------> Works.

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

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

Looking at all these modifications I think we have to really discuss about this implication because a lot of save and load were using bbox_valid_check=False and also now there is no distinctions between load and save and I don't really know if it's a good thing or not.

@@ -70,8 +70,7 @@ def main():
parser.error('Min-Max ufactor "{},{}" '.format(args.minU, args.maxU) +
'must be between -1 and 1.')

sft = load_tractogram_with_reference(
parser, args, args.in_tractogram)
sft = load_tractogram_with_reference(parser, args, args.in_tractogram)
Copy link
Contributor

Choose a reason for hiding this comment

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

missing add_bbox_check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bbox_check=False was not there to start with. I just removed the unnecessary newline.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what you mean with "no distinction between load and save" @arnaudbore

@arnaudbore arnaudbore self-requested a review November 8, 2022 20:36
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@EmmaRenauld
Copy link
Contributor Author

Maybe I can remove this big commit for now, just so that scil_score_bundles can be usable in the next release, and we keep this bigger change for later?

@arnaudbore
Copy link
Contributor

@EmmaRenauld yes go !

@EmmaRenauld
Copy link
Contributor Author

there is no distinctions between load and save and I don't really know if it's a good thing or not.

Same as Antoine. I'm not sure either what you mean. I did not change the way it already was. Even better, I removed the default "False" in many places to make it optional.

But to try and answer... In the case where you need to use it because you have a faulty tractogram, there is a very good change that if a streamline is misplaced in the input, it will also be in the output, no matter what the script does. So I would guess that it's ok in general.

@EmmaRenauld EmmaRenauld force-pushed the fix_bbox branch 2 times, most recently from 2e7736a to 6e8fe6f Compare November 11, 2022 18:55
@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@EmmaRenauld
Copy link
Contributor Author

EmmaRenauld commented Dec 8, 2022

Is this ready, now that the release is done? @arnaudbore
I just rebased on master to verify.

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@frheault
Copy link
Member

@EmmaRenauld Can you update this code with master and then check if everything runs normally.
The master is now up to 3.10 (but should run in 3.8/3.9), so you may have to create a new venv.

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@frheault
Copy link
Member

frheault commented Mar 2, 2023

Out of curiosity, how did you pick which script to change immediately in this PR? Are they all script that runs even with invalid?

@EmmaRenauld
Copy link
Contributor Author

Hmmm.. it was 6 months ago so I don't exactly remember, sorry. I probably searched the word bbox_valid_check in all files.

scripts/scil_decompose_connectivity.py Outdated Show resolved Hide resolved
scripts/scil_remove_invalid_streamlines.py Show resolved Hide resolved
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore arnaudbore merged commit ae48b1b into scilus:master Mar 7, 2023
@EmmaRenauld EmmaRenauld deleted the fix_bbox branch April 6, 2023 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants