Best / quickest way to make maximum projections from multiple z slice and colour channels?


#1

Hi all,

I have confocal images from optically clearing wholemount tissues, so are made of multiple Z slices and usually 4 colours. Typically, after doing some small brightness/contrast adjustments and removing outlier for background steps, I would use image 5d and make maximum intensity Z projections of each channel, plus overlays. Alternatively, I would do the same using hyperstack but I found this takes longer.

I now have quite a few images to get through and I feel like what I am doing is taking longer than it needs to, and can probably be done much more simply. I assume it could be automated but I apologise as I am a complete newbie to scripts.

Does anyone have any advice about how to process large amounts of images like this? Many thanks in advance.


#2

@obh21

Here are some helpful links regarding Scripting in ImageJ/Fiji:

The best way to start is by using the Macro Recorder to record your manual steps into code. Image 5D should be macro-compatible. The workshop & slides linked above go through all that step-by-step. :slight_smile:

If you end up having more questions once you get started … just ask again! We are here to help!

eta


#3

Thanks for this @etarena. One of the problems I have come across when using the macro recorder is saving: is there are a way to save each file with a set file name for each iteration, for example, original file name + DAPI, + DAPI + Cy3 etc. if that makes any sense at all?!


#4

@obh21

Yes - what you will need to do is concatenate strings in order to read in or save files with specified names. You will also need to use variables to save your original file names and file paths, etc.

Take the time to go through that scripting workshop - it’s worth it. It will show you exactly how to do this with clear examples. :slight_smile:

eta


#5

Thank you @etarena . The workshop was really helpful but I am still a really lost when putting it into context with what I want to do.

In order to save iterations of the same image with different channel combinations, I was setting the active channels for each option. ie.

  • z project
  • duplicate
  • set active channel (1111)
  • flatten
  • save as tiff
  • close
  • duplicate original z projection
  • set active channel (0111)
  • Flatten

and so on. However, when I tried to run the scripts I came up with two issues:

  • Despite flattening, all the images are still multi-channel tiffs
  • I have to confirm each time that I want to apply to each image
  • It says a stack is needed to set active channel: i have batch mode set to true, do I need to maybe turn it off and just let it run?

#6

@obh21

Can you post the code you are using as well as an original image (you can also file-share it if needed) that we can run it on… then we can try to help you come up with some improvements/insight.

eta :slight_smile:


#7

Too -

What is your reason to ‘flatten’ the z-projection? Too - you can always split channels, as opposed to setting the active channel, etc. So you’d use code that looks something like this:

#@File(label = "Output directory", style = "directory") outputPath

run("Z Project...", "projection=[Max Intensity]");
run("Duplicate...", "duplicate");
imageTitle = getTitle();
run("Split Channels");
selectWindow("C1-" + imageTitle);
ch1Title = getTitle();
saveAs("Tiff", outputPath + File.separator + ch1Title);
selectWindow("C2-" + imageTitle);
ch2Title = getTitle();
saveAs("Tiff", outputPath + File.separator + ch2Title);