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

Module streamline operations #736

Merged
merged 9 commits into from
Aug 28, 2023

Conversation

EmmaRenauld
Copy link
Contributor

Next step in preparing tests for scilpy: module streamline operations.

Absolutely no line of code was changed here: only moved stuff around, clarifying the folder separations.

Now the 'streamline operation' scripts that we had identified in our previous meeting (@frheault, @AntoineTheb , @AlexVCaron) only import stuff from operation modules, nothing from tractanalysis. They will be ready for tests in a next PR.

  • scil_cut_streamlines.py
  • scil_resample_streamlines.py
  • scil_smooth_streamlines.py
  • scil_compress_streamlines.py
  • scil_uniformize_streamlines_endpoints.py
  • scil_flip_streamlines.py

@arnaudbore arnaudbore self-requested a review August 17, 2023 17:18
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@frheault
Copy link
Member

I like the new organization and I see that all tests are still passing (and I believe all modified scripts were covered). Since this PR is just about moving around things I think the really important PR is the next one where the functions are tested, there is not much to comment on since I agree with the structure and you "only" moved code.

Thank you, it look great!

@EmmaRenauld
Copy link
Contributor Author

Thanks!

I just added a small change, good to go for me!

Copy link
Collaborator

@AlexVCaron AlexVCaron left a comment

Choose a reason for hiding this comment

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

Minor comment, everything else is perfect ! Very nice work

scilpy/tractograms/streamline_operations.py Show resolved Hide resolved
@arnaudbore
Copy link
Contributor

@EmmaRenauld EmmaRenauld force-pushed the module_streamline_operations branch from ef59d02 to 5f8db35 Compare August 18, 2023 14:40
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

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.

One small comment otherwise LGTM

@@ -123,7 +126,7 @@ def _extract_and_save_tails_heads_from_endpoints(gt_endpoints, out_dir):
affine = mask_img.affine
dimensions = mask.shape

head, tail = split_heads_tails_kmeans(mask)
head, tail = split_mask_blobs_kmeans(mask, nb_clusters=2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the extra parameter ? Does it change the behaviour of the function ?

Copy link
Contributor Author

@EmmaRenauld EmmaRenauld Aug 24, 2023

Choose a reason for hiding this comment

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

No. I just moved the function to image.utils because it only takes a mask as parameter, no tractogram. So it felt weird to keep it named split_head_tail. It could split any mask into two blobs. And why not into K blobs, if eventually anyone needs it. So it went from:

Tractanalysis.tools:

    X = np.argwhere(data)
    k_means = KMeans(n_clusters=2).fit(X)
    mask_1 = np.zeros(data.shape)
    mask_2 = np.zeros(data.shape)

    mask_1[tuple(X[np.where(k_means.labels_ == 0)].T)] = 1
    mask_2[tuple(X[np.where(k_means.labels_ == 1)].T)] = 1

To

image.utils:

    X = np.argwhere(data)
    k_means = KMeans(n_clusters=nb_clusters).fit(X)

    masks = []
    for i in range(nb_clusters):
        mask_i = np.zeros(data.shape)
        mask_i[tuple(X[np.where(k_means.labels_ == i)].T)] = 1
        masks.append(mask_i)

    return masks

But I forgot to change the doctstring. Doing it now, thanks.

@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.

LGTM

@arnaudbore arnaudbore merged commit 91c0e5e into scilus:master Aug 28, 2023
@EmmaRenauld EmmaRenauld deleted the module_streamline_operations branch September 22, 2023 15:34
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.

5 participants