Retrieving best focused slice

Dear all,
I’ve got two problem for which, though very simple, I cannot find any help.

1- I’ve got a stack of Z-slices of DAPI stained nuclei and would like to find the best focused one, then work with that slice. MeasureImageQuality works well for that, but then the only way I’ve found to select that slice and work with it is:

  1. Run a first project using MeasureImageQuality and save the scores for all slices into a database (SQLite in my case).
  2. Run a SQLite query to retrieve metadata for best focused slice into a CSV file.
  3. Use that CSV in a second project to load the best focused slice.
    Is there any way these three steps, which I have to load and execute sequentially, can be put into a single project?

2- With the best focused slice identified in the process above, I construct a mask which I want to use over the whole stack of slices for another channel. Could you tell me if there’s a way in which I can match all slices in, say GFP, to one slice in DAPI (from which, later in the project, I generate a mask common to all slices)?
Thanks very much for any help
Best
Carlos

  1. For what you’re explicitly saying you want to do then no, I can’t think of a better way to do it- if you give me a better idea of the broader big-picture goal I can attempt to think of a better way to get at it but there’s no way to get CP to “loop” over your whole stack the first time and then proceed with an action in one single pipeline.

  2. You should be able to do this by extracting Metadata to uniquely identify each movie and then in NamesAndTypes setting the Image set matching method to “Metadata” and configuring it accordingly. Here’s a example from a pipeline where there were many timepoints (which can basically sub in for GFP z planes in your experiment) matched to a single masking image (ala your single DAPI slice)

What you’re requesting in (1) ought to be easier in CP, and in fact others have had similar kinds of workflow problems - e.g., needing to carry out some procedure on the first image in a time-lapse movie and process the remainder of the time-lapse movie based on the results of that.

Given our team is working on 3D analysis at present, it is possible that these kinds of problems could be handled more gracefully. I can’t promise, given that we don’t want to make CellProfiler’s logic confusing for people. But we will at least consider whether these kinds of issues can be handled within-pipeline. I’ve made an issue request here: https://github.com/CellProfiler/CellProfiler/issues/2246

Dear Beth and Anne,
Thank you very much for your replies. I’m sorry I couldn’t reply earlier.
Regarding point 1) it may be a useful feature if autofocus during acquisition is not very good or if offsets vary, especially for different channels. In that case one might acquire a range of slices and pick the best one at analysis time. It shouldn’t be too different from MakeProjection, since a quality measurement is read for each image in a defined group and then at each pass the image with the max/min value of a measurement is retained.
2) Beth’s suggestion worked perfectly well. I was trying to load stacks for two channels, then match every slice of one channel to a single slice of the other channel, with this slice defined in a CSV file. That didn’t work. Saving the selected slice into a file (hence losing slice information) then loading it in a second project workd Ok.
Thanks again for your help
Best
Carlos

1 Like