petersaj / AP_histology

Histology processing
61 stars 21 forks source link

Unrecognized function or variable 'natsortfiles'. #16

Closed Virginia9733 closed 1 year ago

Virginia9733 commented 1 year ago

When I applied AP_histology, encountered this error message:

AP_process_histology(im_path,resize_factor,slice_images); Unrecognized function or variable 'natsortfiles'.

petersaj commented 1 year ago

Hi Muhang - have you added all folders and subfolders of the AP_histology repo to your Matlab path?

natsortfiles is included in the repo at this location: https://github.com/petersaj/AP_histology/blob/master/allenCCF_repo_functions/natsortfiles.m

Virginia9733 commented 1 year ago

HI Peter, thanks for reply! Yes, I forgot to add the subfolder into path...

However, I encountered another issue:

AP_process_histology(im_path,resize_factor,slice_images); 'smooth' requires one of the following: Curve Fitting Toolbox Econometrics Toolbox

Error in AP_process_histology>update_slide (line 301) im_hist_deriv = [0;diff(smooth(im_hist,3))];

Error in AP_process_histology (line 175) update_slide(slice_fig);

I saw someone also have the issue with the curving toolbox, but didn't find the solution for the econometrics tool box? Are these two toolbox required by default?

Thank you

Virginia9733 commented 1 year ago

Also, is there any size limitation for the tiff? The original size is about 819 MB

Virginia9733 commented 1 year ago

I installed curve fitting toolbox, the error disappear, however, the smoothed fig looks a bit strange and I can't adjust the contrast or any interface to do the adjustment. And the Slice_images folder is empty. Screen Shot 2022-10-13 at 4 21 59 AM

petersaj commented 1 year ago

There's no limitation for the tiff, it'll just change the loading time.

For changing the contrast: did you not get screen shown in step 1 in the readme, where it gives a mosaic of black and white images for each channel and asks you to set the color and the white balance?

In your example image, it's detecting the entire slide as a possible slice (which is why the whole slide is outlined in dotted white). This is probably because there wasn't enough slice/background contrast for the automatic detection to work well. But that's no problem - you can manually select the slices by right clicking the mouse, and clicking and dragging to draw a rectangle over a slice, then double clicking to confirm the size. Or, you can try to go back a step and adjust the contrast which might make the auto-detection better.

The slice_images folder is empty because you need to first select slices for it to save (in the step above).

Virginia9733 commented 1 year ago

Hey Andy, thank you for your reply! Yes, strangely I did not get the black and white image as shown in step1. And there is no pop-up asking to change the contrast, that's why I feel a bit weird.

petersaj commented 1 year ago

I see - that'll be because your images are saved as RGB-colored images rather than a stack of grayscale images for each color. Did you do some sort of pre-processing on them, since that shouldn't be how they're natively saved from the microscope? If so, it would probably be easiest to adjust the contrast in your pre-processing program (e.g. ZEN from Zeiss, or whatever you use) before loading them into the histology pipeline.

Virginia9733 commented 1 year ago

I see, thank you so much! Will try!

Virginia9733 commented 1 year ago

Hey Andy, sorry I still have questions.

I tried to save the imaging into a stack tiff, containing DAPI and DiI in the same file, and converted the RGB to 8-bit colour, as shown below: DAPI DiI

Then I tried the codes: % Preprocess images AP_process_histology(im_path,resize_factor,slice_images);

It do pop up the window to ask for contrast adjustment, however, I can't see the dynamic contrast change when I manually change the contrast in the window. It asked what the color of the image, I choose blue first, then choose red, but I can't see any interface showing thecontrast change of the image. adjusting contrast

The tiff remains static and later has this error message. Error when adjusting contrast

Virginia9733 commented 1 year ago

Sorry, I tried to crop the edge of the image to get rid of the distraction. Then merge them as stacks in a single tiff. blue red

Then tried, encountered this error message: error

petersaj commented 1 year ago

Can I check - it looks like your two questions above are quite different, the first one shows color images and you don't see dynamic changes with the contrast tool, and the second one shows black and white images but you're not able to start the AP_process_histologyfunction at all?

Also for the second question when you have an error with AP_process_histology - it looks like you tried to start it twice, but got a different error each time, is that right? The first error looks like it's having an issue with the named contents of your im_path folder - what's in there? The second error happens sometimes when it tries to set the color balance for an image that's completely blank, so it might not have loaded it in properly.

Virginia9733 commented 1 year ago

Sorry for the late response. I still have issue to extract slices from slide automatically, not sure why it can't detect the boundary of the slices even after changing the contrast.

So I skipped this part, cropped the slices manually, and go through the rest of the pipeline. It works! However, I encountered some new errors when I tried to run "AP_view_aligned_histology_volume(tv,av,st,slice_path,1);" view aligned histology volume

Looking forward to hearing from you! Many thanks!

petersaj commented 1 year ago

Great that it's mostly working - if the slice detection is showing the right interfaces and just no dotted lines around the slices, it sounds like the method of finding the intensity cutoff for background vs slice isn't working for you. Could be a few reasons why that's not happening.

The new issue you're having is because that figure has a dependency on this colormap code: https://uk.mathworks.com/matlabcentral/fileexchange/45208-colorbrewer-attractive-and-distinctive-colormaps

I've never cleaned that function up since I don't know anyone that uses it - you could download the brewermap files and add to your matlab path, or you could change the colormap call to something native to matlab (e.g. line 73 from "colormap(brewermap...)" to "colormap(hot)")

Virginia9733 commented 1 year ago

Andy, thanks! It works like a magic, thank you!