Video processing

Hello, I have two pipelines currently. The first pipeline circles my ROI’s and performs image correction.

In the next pipeline i am trying to import video from a .nd2 file type, and use the objects identified in the previous pipeline to measure object intensities as recommended here and here

This is the error message i continue to encounter when i run my pipeline MeasureObjectIntensity.

Traceback (most recent call last):
File “cellprofiler\pipeline.pyc”, line 1956, in run_image_set
File “cellprofiler\pipeline.pyc”, line 2067, in run_module
File “cellprofiler\modules\namesandtypes.pyc”, line 1400, in run
File “cellprofiler\modules\namesandtypes.pyc”, line 1581, in add_objects
File “cellprofiler\modules\namesandtypes.pyc”, line 1515, in add_provider_measurements
File “cellprofiler\modules\namesandtypes.pyc”, line 2048, in provide_image
File “bioformats\formatreader.pyc”, line 950, in load_using_bioformats
File “bioformats\formatreader.pyc”, line 784, in read
File “javabridge\jutil.pyc”, line 931, in method
File “javabridge\jutil.pyc”, line 862, in call
File “javabridge\jutil.pyc”, line 829, in fn
JavaException: Invalid image number: 1 (series=0, imageCount=1)

Why am i getting this? :frowning:
I have updated my java both 32 and 64 bit. (160922-LSL- only install 64 bit java either the jre or the jdk. When you install more than one java, cellprofiler will not load.)

This is the link to the cropped video file.
This is the ROI

and finally, attached is my pipeline
fura2.analysis.cpproj (1007.5 KB)

You’re grouping by “File location”, which if you look at the actual metadata extracted is different because your files have different names (video_crop.nd2 and fura2.roi.tif). If you’re not doing anything like TrackObjects that requires CP to know that these are consecutive frames of a movie you can just turn grouping off altogether, but if you want to be able to analyze more than one movie at a time then you need to set up a metadata extraction from the folder name so that you’re not just matching by something generic like “SizeZ”- there are instructions for how to do that for your images here

After doing your suggestions (along with attempting a single channel video file; with and without groups enabled), I am still getting the error message. Attached is the image from my desktop. I installed the java development kit, since this has helped with other programs; and installed [ilastik](http://ilastik.org/download.html](http://ilastik.org/download.html) out of desperation due to an initial warning from the command line. But, I have still not gotten it to work.

.

Updated pipline
fura2.analysis.cpproj (1.0 MB)

I’m not totally sure why, but it seems to have something to do with the fact that you used “Add as single image” in NamesAndTypes rather than just the normal “add image” - as configured I get the same error you did, but if I make that change it runs fine.

Thank you SOO much :blush:, your seriously helping me out so much. I am trying to take our assay to the next level, because nis elements continues to be unable to automate and i have consistently maxed out the capabilities of the software. So i am willing to do whatever is necessary to solve data acquisition puzzles. So, if you can point me in the direction of resources for source code dissection and module development, i would really appreciate that.

One thing though, i don’t believe it is measuring all of my objects? It is maxing out around 253 objects, but i have selected 2347 objects. in my previous pipeline.

Have i done something wrong for my object import?
I updated my ROI to this, and saved in various formats (bmp will not save in saveimages, and the 2nd pipeline doesn’t recognize .mat as image). So seem to be stuck with the .tif format.

This is the pipeline i use to develop and save my objects
Pipeline for 4x objective.cpproj (809.7 KB)
And this is the pipeline i use to measure object intensity changes.
fura2.analysis.cpproj (108.1 KB)

Also, i promise to make a tip/tutorial for this once i get it figured out. I also have some fantastic interactive R functions developed i would like to share for this type of analysis.

My guess is that it’s because in your previous pipeline you converted the objects to an image and then saved them as an 8bit image- and there are 256 possible grey levels in an 8 bit image. Try saving the objects directly (at the top of SaveImage, it allows you to select Objects as an input) and upping your bit depth.

Also, the source code of CellProfiler is at https://github.com/CellProfiler/CellProfiler

Your a wizard. Let me add a few notes to this discussion for future reference.

Saving the ROI as an object but as color has a bit depth of 24, which is actually three 8-bit channels

When i save as my object as gray-scale. The image becomes single channel image with 16-bits per channel.

The warning is within the save-images > Save as grayscale or color image question mark (?)

Okay,

So, now how do i speed up the process. The only measurement i need from MeasureObjectIntensity is mean intensity. This is very important, because if i want a more rapid data extraction, i need to drive down the 1 hour data extraction time.

I suspect this module is doing every single measure underneath the ExportToSpeadsheet module, see attached image

Will something need to be developed for optional selection of object intensity measurements?

Thanks

I suspect this module is doing every single measure underneath the ExportToSpeadsheet module, see attached image

You suspect correctly

Will something need to be developed for optional selection of object intensity measurements?

I doubt it; it would massively increase the complexity of the UI for probably a limited time gain.

So, now how do i speed up the process.

My suggestion would be to look at the output window- buried in amongst the non-error error messages (which we know is annoying, our software engineers are working on fixing it), you should find for each image a line that looks like this

Wed Sep 21 14:44:50 2016: Image # [some number], module MeasureObjectIntensity # 5: [some number] sec

According to your screenshot you’re averaging about 22 images per minute, or about 20 seconds per worker per image. If the value of MeasureObjectIntensity is close to 20 seconds then there’s nothing more you can do (at least running on that particular machine); if it’s relatively small compared to 20 seconds, you could try to use the LoadData module or even run from the command line, as those may speed up the image loading.

20 seconds doesn’t seem that bad to me for loading the images, measuring ~2400 ROIs and then reporting the value for each of them, but of course YMMV.

I am getting a average of .39/sec for the module MeasureObjectIntensity.
but 1.39/s for names and types

How would the LoadData Module work to speed up my process?

And how do i run from the command line?

20 seconds doesn’t seem that bad to me for loading the images, measuring ~2400 ROIs and then reporting the value for each of them, but of course YMMV.

The program i am trying to replace does this process in under 10 minutes , so i really hope i can speed this up to make it a viable alternative.

I’m not sure why exactly the LoadData module makes loading faster, but I believe it has something to do with the fact that your images are then pre-metadata extracted, arranged into sets, etc. You can try exporting a CSV from your current pipeline with Export->ImageSetListing, then making a copy of your pipeline and placing LoadData at the top (it’ll replace the first 4 modules).

Command line may or may not be faster just because it’ll only be a single thread rather than 8 at a time (but it won’t have to support the GUI). More info can be found here and here.

FWIW, our software engineer says that while he doesn’t have proof he thinks the slow step may be ExportToSpreadsheet, in which case none of this will help. Probably worth doing the experiment though!

LoadData module takes .5 s/img,
Whereas NamesAndTypes takes 1.46 s/img
despite those values, i am still running at 24 images/minute
But, i guess this prevents me from automating multiple experiments?

The data indicates that
ExportToSpreadsheet is 0.00 s/img

I tried the experiment of ExportToSpreadsheet un-checked, and the pipeline ran at the same speed.

I really wonder if a for-loop would speed this up at all in the source code, since it is only running 8 objects seperately at a time.

I’ll dive into the batch processing, and command-line operations.

Once again, Thank you so much for your help. I will post any updates to my current process that speeds things up.

This software is amazing.

But, i guess this prevents me from automating multiple experiments?

I don’t see why- you could load multiple videos into a pipeline, all of which will have their bespoke ROIs matched to the video by the metadata, then walk away and let your computer run overnight (or all weekend). Unless I’m misunderstanding you?

Here is my request and information on processing speed to reactivate an older request from this question.

I think you are right. I am going to bite bullet for time to process in trade for the automation.

Any idea, why it takes so long. It seem like there is some gummy process causing the per image change to slow down a lot.

I don’t know, sorry. I DO know that our engineers are trying to strip image loading down and rebuild it for CellProfiler3 for precisely these types of reasons, so hopefully we’ll see a big performance boost whenever that work is completed.

Did LoadData help at all?

I will be extremely excited for Cell-Profiler 3 then.

Load Data, actually gave me the same overlying rate, so i think the image loading/under the hood stuff is taking the longest.

One more question. If i create objects in one pipeline, and load it in another, will the objects have the same id, or will i need to assign names per location.

If your object numbers are consecutive (ie haven’t gone through a filtering step where you told them to maintain their old object numbers), I believe they should maintain their numbers across pipelines since their numbers are based on their center’s XY position; you can verify downstream if you need to by looking at the object number and position to make sure.

I don’t know what happens if you had non-consecutive numbers. It may maintain the numbering schema by using the stored greyscale values, or it may renumber based on centers.