Need help with cell counting -ID secondary objects

Dear All,
I have a problem I can’t seem to figure out, though it does seem fairly straightforward.
I have images where I want to count the GFP positive cells, and compare them the numbers of total cells.
How think I should be going is to ID the cells by their nuclei, then simply get a radius around them (since not all cells are visible in the GFP channel), and measure the intensity. The overall median intensity can be used to then to see how many cells are positive, and how many are not.
Now, here’s the problem: the cells are fairly tightly packed. If I simply set a diameter around them, the secondary object module will find all sorts of weird stuff - after all, one cell’s cytoplasm will touch the others’, and if it’s fairly close to the nucleus, then one cell’s positive staining can “spread out” as false positives to the neighbors.

The question is twofold, really: am I on the right track, and how should I modify it to make it more specific?

Thank you for your help. I really appreciate it.

Is it possible to just measure the GFP signal from the nuclei object alone, and not worry about the area outside the nuclear region? If not, it may be helpful to upload some example raw images to show what the phenotype looks like.

If they cells are confluent to the point where there’s a large degree of overlap between adjacent cells, it may not be possible to tell which GFP signal belongs to which cell…

Regards,
-Mark

Thank you for the quick answer. It is a very good idea just to use the area of the cell nuclei only (well, with 1 pixel diameter around the nuclei). Though the green is obviously fainter right at that area, it still seems to be much higher than the background, so this should not be a problem.
I uploaded an image from the identify secondary object picture, and this shows my issue: although there are only three positive cells (one’s even outside of the field), the cytoplasms overlap with other nuclei -making those cells appear positive.

Is it possible that if I take the median intensity instead of the mean most of these cells will be filtered out? (The staining is not as uniform as in the bona fide positive cells.)

How does one go about actually analyzing the data? I really just need to know how many nuclei vs how many green cells I have.

Thank you again; I really appreciate your patience.


For a ready-made example of how to get these counts, I suggest looking at the “Cell/particle counting, and scoring the percentage of stained objects” pipeline on our Examples page. It will need some adjustment for your images (as per the discussion above), but the principle should be the same.
-Mark

Thank you very much.

Another question has come up; my apologies. Tried to find the answer online (manual, FAQ, forum), but I can’t figure out what the “nearly complete” properties file mean, that is generated by Cell Profiler. I keep looking over the file, but obviously are missing something, as the Analyst does not start when I try to load it.

Thank you for your patience.

ExportToDatabase will create a properties file for you to be used as input for CellProfiler Analyst (provided you check the “Create a CellProfiler Analyst properties file?” box is checked). The module will attempt to fill in as many fields as it can based on the information available in the pipeline. Do you get an error when you open the properties file with CPA?
-Mark

Sorry for dragging this out for so long, but it’s been quite difficult to make this thing work. (This post has been edited heavily as I figured some things out. Apologies.)

Right now I can open up the Analyst using the properties file generated by the **sqlite **mode, but it does not find the images. Even though the path and filename are correct in the error message, it cannot open the tif files at the image viewer-at least this is the error message. I’m not sure what to do with this. (Just to be on the safe side I coped both the outline images generated by cell profiler to the original directory, and the image files into the output directory.

This is the message:
*An error occurred in the program:
Exception: Could not open image: “C:\0 Powell\cell profiler\2011 12 07 HEK-TR339 2hpi titration on BHK\2011 11 30 HEK-TR 2hpi titrated on BHK 1_1 1_c2.TIF”

Traceback (most recent call last):
File “cpa.py”, line 270, in launch_image_viewer
File “imageviewer.pyc”, line 216, in init
File “imageviewer.pyc”, line 552, in OnOpenImage
File “imagetools.pyc”, line 52, in FetchImage
File “imagereader.pyc”, line 26, in ReadImages
File “imagereader.pyc”, line 81, in read_images_old_way
File “imagereader.pyc”, line 123, in ReadBitmap
File “imagereader.pyc”, line 168, in GetRawData
*

I think the location of the images might be the problem for the analyst somehow, even though it is looking for them in the right place.

When I use msql/scv then the SQL_1_40_Object.CSV files will not contain headers. (See the files.) None of those files (image/object) contain anything like what the cell profiler analyst manual specifies (chapter IA). I used both the export to spreadsheet and the export to database module, so I have two sets of csv files. The image and cell files generated by the export to spreadsheet module do not contain any information about the images location, but it does have the necessary headers that define what the different columns actually mean.

When I try to open up the Analyst using this properties file generated by this module, however, nothing happens -probably because it is looking for the header information.

I found a really good exercise online how to classify cells using cell profiler and analyst, but the metadata they used was in a csv file to begin with, and both programs used that. I don’t have the metadata prepared this way.

I uploaded the properties files as well. Since the forum did not allow either the .properties extension or .txt, I renamed them .csv.

I really appreciate your help, and I wish you a merry Christmas.
sqlite_DefaultDB_properties.csv (6.45 KB)
mysql_csv_DefaultDB_properties.csv (6.43 KB)
SQL_1_40_Object.CSV (7.93 MB)
SQL_1_40_Image.CSV (45.5 KB)

Hi,

I wanted to clarify a few things based on your descriptions. I think there may be some confusion as to what files are required for each format:

  • One properties file that you sent as dbtype = mysql
    . This indicates that the database of measurements is on a remote server somewhere, which is not true in your case. So using this as *dbtype *will not work. - Your other properties file sets dbtype = sqlite
    , with two CSV files, prefixed with “SQL_1_40”. By the nomenclature, I can see that these CSVs were generated by ExportToDatabase with the MYSQL/CSV setting.
    Unfortunately, this is not the proper way to use these CSVs in the properties file. There should have been another file, named similarly to DefaultDB_Setup.SQL, placed in your output folder. It is this file that contains the header information that is missing from the CSVs. To use it, all you need in the “Database Info” part of the properties file is the following:

db_type = sqlite db_sql_file = <path and filename of .SQL file from ExportToDatabase> - You mentioned that you also produced CSVs from ExportToSpreadsheet. These can be used in the properties file in the following way:

db_type = sqlite image_csv_file = <path and filename of image csv> object_csv_file = <path and filename of object csv> in this case, the header information is in the CSV, and the setup.SQL file is not needed. However, the filename and pathname information must be in the CSV. If you used “Select the columns of measurements to export?” in ExportToSpreadsheet to omit the filename and path information, this approach will not work.

You say that you have successfully opened the properties file generated in sqlite mode, so I assume that you have sqlite database (named something like DefaultDB.db) sitting in your output folder.

That said…

[quote=“spongya77”]
This is the message:
An error occurred in the program:
Exception: Could not open image: "C:\0 Powell\cell profiler\2011 12 07 HEK-TR339 2hpi titration on BHK\2011 11 30 HEK-TR 2hpi titrated on BHK 1_1 1_c2.TIF"

Are you certain that the file “2011 11 30 HEK-TR 2hpi titrated on BHK 1_1 1_c2.TIF” exists in C:\0 Powell\cell profiler\2011 12 07 HEK-TR339 2hpi titration on BHK? at the time you gave this a try?

Regards,
-Mark[/quote]

Thank you for your help; it indeed makes more sense. (As you can see I’m not good at sql.)
So far I have made analyst load the dataset; however, when I tried to run the classifier, it seems it cannot find the cells. It loads a bunch of empty boxes (See image).
I noticed that in the properties file it usually asks for the x and y axes in a format of

cell_x_loc = Image_Location_Center_X
cell_y_loc = Image_Location_Center_Y

but when I load the data from the csv file the coordinates are in a Location_center_x/y column; changing the lines does not help, however.

cell_x_loc = Location_Center_X
cell_y_loc = Location_Center_Y

Once I made it in so that the first box did have one cell in it, but I had to solve some issues with the pipeline (which were successful), but now I can’t even get the first box full…

I really appreciate your patience. I’m trying to work things out myself first, and not run to you at the first problem, but I’ve been at it for almost the whole afternoon, and I can’t see what is wrong. Something very simple, probably.
Thank you.

(By the way, the path was indeed wrong; I messed up. After processing a batch I put a “done” at the end, to remind me which ones were finished. Obviously the software did not find them after that. Sorry about it…)


[quote=“spongya77”]
but when I load the data from the csv file the coordinates are in a Location_center_x/y column; changing the lines does not help, however.

cell_x_loc = Location_Center_X
cell_y_loc = Location_Center_Y[/quote]

These fields don’t seem to be quite right. The location of each object is typically defined as a measurement with the nomenclature “<object_name>_Location_Center_X” and “<object_name>_Location_Center_Y”. There should be an object (such as “Nuclei” or “Cell”) as the prefix, which depends on the names you used in your pipeline. You may want to check this in your properties.

That’s good to hear! :smiley:
-Mark

I think it works now… I can’t believe it. I would like to buy you a beer or a drink of your choice should you happen to visit England. Thank you very much for your help and patience. I really, really appreciate it.

Hello again… I tried to work on other images, other property files, and this is what I get when I try to open an image in Analyst.
The names and the paths are correct this time… and I can’t figure out what the problem is.
I used the sqlite option in export database, and got a DefaultDB.db file.
When I check the column names in analyst, they are the same ones as the ones in the properties files. I know it’s different from the export settings that worked previously, but I’m not sure why it does not work. (Don’t ask me why I don’t use those settings; I’m a bit confused having all these .cp files around… Not sure which one I used before.)

An error occurred in the program
IndexError: list index out of range

Traceback (most recent call last):
File “cpa.py”, line 270, in launch_image_viewer
File “imageviewer.pyc”, line 216, in init
File “imageviewer.pyc”, line 552, in OnOpenImage
File “imageviewer.pyc”, line 249, in SetImage
File “imageviewer.pyc”, line 55, in init
File “imagepanel.pyc”, line 31, in init
File “imagetools.pyc”, line 121, in MergeToBitmap
File “imagetools.pyc”, line 165, in MergeChannels