Neural-Systems-at-UIO / nutil

https://nutil.readthedocs.io/en/latest/
GNU General Public License v3.0
12 stars 5 forks source link

High resolution PNG maps with greater anatomical distinction #319

Open Sathyanesan-Lab opened 3 months ago

Sathyanesan-Lab commented 3 months ago

I tried using a modified python code to read the flat file that is generated as part of the QUINT workflow, however, the output is a low-res PNG. What would I need to do in order to get a high-res PNG similar to what is the final output images using NUTIL? I am specifically interested in extracting the distinct cerebellar nuclei. If each of these nuclei have different colors, I can use fiji to extract ROI based on color information. However, currently the labeling in the final output of NUTIL yields the same color for all cerebellar nuclei.

However, since I do not need object counts, I just obtained the high-res color images using empty segmentation images in the NUTIL workflow. I got the high res maps but the distinct nuclei do not show up. I tried using one of your answers to relabel the label.txt file, but I am unsure how to proceed from here. Because the json file which was exported from Visualign does not open up in visualign itself. So, how would I go about getting only the high-resolution PNGs with each of the cerebellar nuclei (fastigial nucleus, interposed nucleus, and dentate nucleus) distinctly labeled?

sharoncy commented 3 months ago

Hi @Sathyanesan-Lab. There is a workaround in Nutil for this which doesn't involve coding (where the Nutil output images display colourised regions-of-interest instead of objects). Basically you run the QUINT workflow as normal, but instead of using segmentation displaying objects-of-interest and quantifying these objects, you create segmentations where everything is displayed in one colour (for example, black images, every pixel is RGB: 255,255,255). The segmentations have to meet the usual QUINT requirements (PNG format with the same proportions as the images registered to the atlas with QuickNII/VisuAlign but can have higher resolution). Basically, the output images from Nutil will have the same size as the input segmentations so you can choose how high-res you want to go.

To get the output images from Nutil to display your regions-of-interest in unique colours, define your own custom regions using the CustomRegionTemplate.xlsx and assign each region a unique colour (https://nutil.readthedocs.io/en/latest/QuantifierReports.html). By running Nutil to quantify the entire segmentation (select object colour: black) with custom regions (e.g. fastigial nucleus, interposed nucleus, etc), you'll get high-res PNG images from Nutil with your regions-of-interest colourised as defined in the xlsx file. As Nutil quantifies the entire segmentation here (which is time consuming, especially if the segmentations are large), the trick is to switch off coordinate extraction in the advanced settings (this is the most time consuming part). Also make sure to switch off the option to display object IDs and region IDs in the image files. If it is still too time consuming (or Nutil crashes), try reducing the size of the segmentations.

Hope this solution is useful, Best regards, Sharon

Sathyanesan-Lab commented 2 months ago

Thank you for the response! I tried this solution. But the output images did not have the desired regions colorized. I have attached an example of the input segmentation and the corresponding output image. The input image had a red LUT and I selected red as the object to be counted. The customizedregion xlsx file has also been attached. I also attached screenshots of the nutil parameters. INPUT: f1r1_ALT_gad_lide1_1_s001_Simple Segmentation OUTPUT: f1r1_ALT_gad_lide1_1_s001_Simple Segmentation NUTIL PARAMETERS and OUTPUT log: Screenshot 2024-09-04 144231 Screenshot 2024-09-04 144316 Screenshot 2024-09-04 144341

CustomRegionTemplate.xlsx

Also, here is the json file: ts-gad.json

sharoncy commented 2 months ago

Hi @Sathyanesan-Lab. I inspected your files and everything looks fine. I forgot to mention that "object_splitting" in Nutil must be switched to "yes", otherwise it won't work. Hopefully this should fix it for you. If you still have problems, I'd be happy to test some more, but I need an example segmentation file (generated from a brain section containing your regions of interest) and a corresponding flat file, in addition to the files above. You can email them to s.c.yates@medisin.uio.no. Good luck.

sharoncy commented 2 months ago

Something I forgot to mention. The custom region colours that you selected for the different nuclei in the CustomRegionTemplate are basically the same (similar shades of yellow). Using this template, I don't think you'll be able to differentiate between the nuclei by eye (although ImageJ will be able to differentiate between them). I suggest changing the colours so it's easier to differentiate between them (don't use red as Nutil automatically assigns red to the background).