FAST-Pathology icon indicating copy to clipboard operation
FAST-Pathology copied to clipboard

Converting segmentation.tiff to 'imagename'.tiff

Open ajr82 opened this issue 1 year ago • 10 comments

This is just a query.

I am running FastPAthology v1.0.1 on Win 11.

I run a pipeline for all images in my project. Is there a way to name the .tiff result file to 'image filename'.tiff (instead of segmentation.tiff) and create all .tiff files in a single folder for the project instead of them being within subfolders for each WSI image? This will make it easier for importing the annotations into QuPath.

Thank you!

ajr82 avatar Aug 23 '22 15:08 ajr82

There is no way to that right now in the software. But it can be accomplished quite easily with a python script which renames/moves the files afterwards.

Is this a standard format/structure that qupath uses for importing data? If so, we can consider making an export function in FastPathology which does this.

smistad avatar Aug 23 '22 19:08 smistad

@ajr82 You are probably referring to importing the segmentation TIFF to QuPath using this script, right? https://github.com/andreped/NoCodeSeg/blob/main/source/importPyramidalTIFF.groovy

If I remember correctly, I have updated this script locally, but have probably not updated it to the NoCodeSeg repo. When I get to work tomorrow I can check and update you on the manner.

Import of predictions from FP into QuPath should then work out-of-the-box, as it did for the older FP version. There should not be a name to change the naming pattern. This is easier solved by updating the groovy script which we use to import the predictions in QuPath.

andreped avatar Aug 23 '22 19:08 andreped

Thank you for your reply. It is not the QuPath standard. I am using the NoCodeSeg scripts and therefore it makes it easy. I thought that we could maybe specify the name/folder on the pipeline file and thats why I asked. I can use a Python script. No problem!

ajr82 avatar Aug 23 '22 19:08 ajr82

@ajr82 You are probably referring to importing the segmentation TIFF to QuPath using this script, right? https://github.com/andreped/NoCodeSeg/blob/main/source/importPyramidalTIFF.groovy

If I remember correctly, I have updated this script locally, but have probably not updated it to the NoCodeSeg repo. When I get to work tomorrow I can check and update you on the manner.

Import of predictions from FP into QuPath should then work out-of-the-box, as it did for the older FP version. There should not be a name to change the naming pattern. This is easier solved by updating the groovy script which we use to import the predictions in QuPath.

@andreped, exactly! Okay, thank you very much!

ajr82 avatar Aug 23 '22 19:08 ajr82

@ajr82 I just tested inference with FP now and I reproduced the issue. I also found that: 1) the folder structure has changed in the new version of FP and 2) for certain images the mhd/raw format is preferred over TIFF.

  • Issue 1) is not really an issue. This can easily be solved by updating the import groovy script in NoCodeSeg.

  • Issue 2) is more challenging. QuPath cannot read mhd/raw files. Hence, it would be better to use the same TIFF format for all types of segmentation results. We will look into this, but I assume that you only have TIFF images in your results folder (hopefully).

mhd/raw format will be used if the WSI you are using is very small, too small were a pyramidal format makes sense. However, it is more optimal to use the same format (TIFF) for both, if possible.

I have tested loading segmentations in QuPath, and with the updated script it appears to take a tremendous amount of time. Hence, it is probably better if we try to make a proper fix for this and let you know if this has been fixed in the upcoming release.

Alternative solution: As you are unable to import predictions from FP into QuPath, I would suggest running inference through MIB (for now) - the same software you were training in. Then you can import the predictions from MIB into QuPath using this script: https://github.com/andreped/NoCodeSeg/blob/main/source/importStitchedTIFfromMIB.groovy

Remember to run inference on full WSIs in MIB (on not just patches), because this script expects stitched segmentation TIFF images. Also remember to update the hyperparameters to match your setup: https://github.com/andreped/NoCodeSeg/blob/main/source/importStitchedTIFfromMIB.groovy#L27

This should work as before. If you are experiencing any issues with running predictions on full WSIs in MIB and importing these in QuPath, please, feel free to ask for help :]

andreped avatar Aug 24 '22 14:08 andreped

@ajr82 I also opened an Issue on the NoCodeSeg repo to track this issue. You can also reply there if it is related to interacting with MIB and QuPath: https://github.com/andreped/NoCodeSeg/issues/12

andreped avatar Aug 24 '22 14:08 andreped

@andreped thank you for looking into this. Like you mentioned, I noticed that some of the WSIs have a mhd/raw output, while others have a .tiff output. I was wondering why and it is good to know now that this it is because of the size.

I will continue to run the whole WSI/MIB workflow as before.

ajr82 avatar Aug 24 '22 15:08 ajr82

@ajr82 import of predictions on full WSI from MIB into QuPath is working fine with the other script in NoCodeSeg?

andreped avatar Aug 24 '22 15:08 andreped

@andreped I have been using both the tile-based and full WSI annotation methods to import into QuPath from MIB. Both methods work well. I do notice subtle changes in the output from both these methods. Although full WSI annotations are much faster and easier. Thank you!

ajr82 avatar Aug 24 '22 18:08 ajr82

Although full WSI annotations are much faster and easier.

@ajr82 Full-WSI prediction is absolutely the way to go! It is also easier to maintain and more streamlined, especially when new WSIs are introduced.

But great that the pipeline is working for you :] Looking forward to seeing the results!

Will update you when the TIFF-stuff is fixed in FP.

andreped avatar Aug 24 '22 18:08 andreped

@ajr82 Just fixed the path-thingy in NoCodeSeg to be compatible with the latest release of FastPathology: https://github.com/andreped/NoCodeSeg/commit/9714fb170beeb28958d4d51cb6bb934bd4935635

@smistad also fixed the formatting issue, such that all generated segmentations from FP should now be stored in the same TIFF-format.

We aim to make a new release of FP next week which includes this fix.

andreped avatar Sep 09 '22 16:09 andreped

Thank you very much!

ajr82 avatar Sep 09 '22 16:09 ajr82

@ajr82 For testing the updated NoCodeSeg script, could you use the nightly release of FastPathology? It is available from here: https://github.com/smistad/FAST/actions/runs/2866558364


EDIT: Oh, nevermind! That is of course the latest FAST artifact and not FastPathology artifact. Will let you know when that is ready :)

andreped avatar Sep 09 '22 17:09 andreped

@ajr82 Hello! Just letting you know that this has been fixed in the latest artifact, which will be made available as a release soon.

See this thread for some information regarding the issue https://github.com/AICAN-Research/FAST-Pathology/issues/49

On Windows, you can download this artifact (note that you have to be signed into GitHub to see it): https://github.com/AICAN-Research/FAST-Pathology/actions/runs/3282310803

Just click the file Windows package and it should download the windows installer for you.

@sahpet You could also test if you are able to run your segmentation models and import these into QuPath, if you have the time.

andreped avatar Oct 20 '22 08:10 andreped

Thank you very much!

ajr82 avatar Oct 20 '22 12:10 ajr82

@ajr82 I'm closing this issue for now. If you are having any problems related to this, please, reopen. For other issues, make a new issue. And of course, please, report to me if it worked :) Good luck!

andreped avatar Oct 20 '22 13:10 andreped

@ajr82 this fix has now been made available in the latest release: https://github.com/AICAN-Research/FAST-Pathology/releases/tag/v1.1.0

All segmentation results should now be stored in the same pyramidal TIFF format, which in turn means that we can import these in QuPath seemlessly.

andreped avatar Dec 06 '22 10:12 andreped

@andreped @smistad thank you for the information. We have been using FAST-Pathology+NoCodeSeg+QuPath (and MIB for training). No more tiling or jpeg of WSIs with FAST-Pathology and this has improved our workflow significantly.

ajr82 avatar Dec 07 '22 20:12 ajr82