JaneliaSciComp / multifish

EASI-FISH analysis pipeline for spatial transcriptomics
BSD 3-Clause "New" or "Revised" License
32 stars 13 forks source link

Feature request: add standalone pipeline for segmentation #8

Open KMSmichelle opened 2 years ago

KMSmichelle commented 2 years ago

Bug report

Hi, I tried to follow the steps "https://janeliascicomp.github.io/multifish/QuickStart.html" for installation, i suceed to install Nextflow and Singularity, and clone the repository, and found the "download_dataset.sh" is not available in the current version:

Provided the error: (multifish_conda) kms102104:~/multifish$ ./setup.sh Extracting Starfinity model... ./setup.sh: line 18: /home/kms102104/multifish/data-sets/download_dataset.sh: No such file or directory

I wish to try your segmentation tool individually as th overview page intoduced that some of these modules can be executed individually, using alternative main-*.nf scripts in the root project directory. However, i couldnt find "main-segmentation.nf" file in the git. Please help. Thank you.

Environment

krokicki commented 2 years ago

Hi, @KMSmichelle ,

Thanks for reporting this, we have fixed the error.

Currently, we don't have a way to run the segmentation alone, but we'll definitely consider adding that for a future release.

As a workaround in the meantime, you could run the main pipeline and skip every step except segmentation: --skip stitching,spot_extraction,registration,warp_spots,measure_intensities,assign_spots

You'll would just need to stage your input data into the stitching/acq_name/export.n5 directory, which is where the segmentation step expects it. I recommend running the demo_tiny test so that you can see what the file structure looks like, and then mimic that.

Best regards, Konrad

KMSmichelle commented 2 years ago

Thanks @krokicki , I tried ./setup.sh and it works ! Thanks for the suggestion, I am trying "demo_tiny.sh" without skipping any step, to understand the whole workflow, but I met another error , see #9

wangyuhan01 commented 2 years ago

Hi, @KMSmichelle ,

Thanks for your interest in the pipeline! You should be able to run segmentation independently on a workstation with gpu.

Starfinity can be installed directly with pip. pip install git+https://github.com/mpicbg-csbd/stardist@refinement

For testing segmentation with our model, you can download our model here. And you can run the attached .py code to generate predictions (tif files work fine). If you would like to train your own model, please also install Augmend and gputools (optional).

Hope this helps! starfinity_prediction.py.zip

Best, Yuhan

KMSmichelle commented 2 years ago

Dear Yuhan,

Thanks a lot for your email and information. I found the python code from branch ‘refinement’ after searching more on the Stardist github page, I am currently testing it on my images. The available model works pretty well, and I believe own training set may improve the performance. I have generated own model using the “training” script from @.*** , the augmentation seems not using ‘augmend’ as recommended in your previous email. If I would like to use “Augmend”, is the following code applicable or additional code is required?

(taken from @.***)

augmenter = None

def augmenter(X_batch, Y_batch): """Augmentation for data batch. X_batch is a list of input images (length at most batch_size) Y_batch is the corresponding list of ground-truth label images """

...

return X_batch, Y_batch

Thank you.

Best regards, Michelle

From: Yuhan Wang @.> Sent: Monday, February 28, 2022 5:57 AM To: JaneliaSciComp/multifish @.> Cc: KONG Mei Suen Michelle @.>; Mention @.> Subject: Re: [JaneliaSciComp/multifish] Feature request: add standalone pipeline for segmentation (Issue #8)

Hi, @KMSmichellehttps://github.com/KMSmichelle ,

Thanks for your interest in the pipeline! You should be able to run segmentation independently on a workstation with gpu.

Starfinity can be installed directly with pip. pip install @.***

For testing segmentation with our model, you can download our model herehttps://doi.org/10.25378/janelia.13624268.v1. And you can run the attached .py code to generate predictions (tif files work fine). If you would like to train your own model, please also install Augmendhttps://github.com/stardist/augmend and gputoolshttps://github.com/maweigert/gputools (optional).

Hope this helps! starfinity_prediction.py.ziphttps://github.com/JaneliaSciComp/multifish/files/8149490/starfinity_prediction.py.zip

Best, Yuhan

— Reply to this email directly, view it on GitHubhttps://github.com/JaneliaSciComp/multifish/issues/8#issuecomment-1053695652, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWQOD6EQ52CRIR6JAJOQNYDU5KM4JANCNFSM5NRGL6BA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.**@.>>

This e-mail and any attachments are only for the use of the intended recipient and may contain material that is confidential, privileged and/or protected by the Official Secrets Act. If you are not the intended recipient, please delete it or notify the sender immediately. Please do not copy or use it for any purpose or disclose the contents to any other person.

wangyuhan01 commented 2 years ago

Hi Michelle,

Depending on the type of augmentation you would like to do, you may change the function to something like this. Please refer to Augmend for details of these function.

from augmend import Augmend, FlipRot90, Elastic, IntensityScaleShift, AdditiveNoise

def augmenter(x,y):
        aug = Augmend()
        aug.add([FlipRot90(axis=(1,2)),FlipRot90(axis=(1,2))])
        aug.add([IntensityScaleShift(scale_range=(.5,2), shift_range=(-.5,.5)),Identity()])
        aug.add([Elastic(axis = (0,1,2),amount=6, grid =6, order=0, use_gpu = True),
                 Elastic(axis = (0,1,2),amount=6, grid =6, order=0, use_gpu = True)],
                probability=.8)
        aug.add([AdditiveNoise(sigma=0.03),Identity()], probability=.5)

        return aug([x,y])

Also in model.train(X_trn, Y_trn, validation_data=(X_val,Y_val), augmenter=augmenter)