FilterByObjectMeasurement problem


#1

Hi,

I made a pipeline on CP 1.0.5122. It was working well.
I’d like to upgrade to 5811 so I installed the last release (bugfix branch).
Some modules changed, in particular FilterByObjectMeasurement. In this one, a new parameter was added:

For TEXTURE, RADIAL DISTRIBUTION, OR NEIGHBORS features, what previously measured size scale (TEXTURE OR NEIGHBORS) or previously used number of bins (RADIALDISTRIBUTION) do you want to use?

The problem I got happens when I use MeasureObjectNeighbors module just before. I consider neigbors when 2 nuclei if
they are within a distance of 3 pixels. Then, when I want to filter nuclei that have at least 1 neighbor, it fails raising the
following error :

There was a problem running the anlysis module FilterByObjectMeasurement module which is number 35. Attempted to access FieldnumsCategory(1); index out of bounds becasue numel(FieldnumsCategory)=0. Image processing was canceled in the FilterByObjectMeasurement module (#35) because an error ocurred when retrieving the data. Likely the category of measurement you chose, Neighbors, was not available for Nuclei with feature 1possibly specific to image 'RescaledGreen' and/or Texture Scale = 3.

[size=85]error raised at line 123, FilterByObjectMeasurement[/size]

NB: ‘RescaledGreen’ is the image name I gave to FilterByObjectMeasurement parameter #5
(It is supposed to only affect the display).

I think it tries to get Neighbors_NumberOfNeighbors_RescaledGreen_3 value but I’m not sure
this is created in MeasureObjectNeighbors.

I have no idea of the reason of that error. Can somebody help me on that ?
Thanks

p-j


#2

Yes, I also get that same error (below) whenever I put ANY module after MeasureObjectNeighbors. The output .mat file always contains the appropriate Neighbors measurements, but none of the modules seem to be able to access this data.

[quote]There was a problem running the analysis module ClassifyObjects which is number 04.
Attempted to access FieldnumsCategory(1); index out of bounds because numel(FieldnumsCategory)=0. Image processing was canceled in the ClassifyObjects module (#4) because an error ocurred when retrieving the data. Likely the category of measurement you chose, Neighbors, was not available for Nuclei with feature number 1, possibly specific to image ‘OrigRed’ and/or Texture Scale = 200.

Stack:
ClassifyObjects in C:\Program Files\CompiledCellProfiler\CellProfiler_mcr\Modules\ClassifyObjects.m (126)
AnalyzeImagesButton_Callback in C:\Program Files\CompiledCellProfiler\CellProfiler_mcr\CellProfiler\CellProfiler.m (10442)
gui_mainfcn in C:\Program Files\CompiledCellProfiler\CellProfiler_mcr\CellProfiler\CellProfiler.m (12182)
CellProfiler in C:\Program Files\CompiledCellProfiler\CellProfiler_mcr\CellProfiler\CellProfiler.m (57)[/quote]


#3

I think I have found the problem. In CPgetfeaturenames, the handle for this data structure is generated withCurrentMeasure = [CPjoinstrings(Category,'.*',Image,num2str(SizeScale)),'$'];, but this does not create the right name for the Neighbors structure. I have edited my file to include the following: if strcmp(Category,'Neighbors') CurrentMeasure = [CPjoinstrings(Category,'*',num2str(SizeScale))]; FieldnumsCategoryCell = regexp(AllFieldNames,CurrentMeasure); FieldnumsCategory = find(~cellfun('isempty',FieldnumsCategoryCell)); % Could do error checking here, since the next line is where this subfn usually errors % (if it can't find a FeatureName), but we ought to use 'try/catch' in the % calling function, for better error handling FeatureName = AllFieldNames(FieldnumsCategory(FeatureNumberOrName)); elseif isnumeric(FeatureNumberOrName) CurrentMeasure = [CPjoinstrings(Category,'.*',Image,num2str(SizeScale)),'$']; FieldnumsCategoryCell = regexp(AllFieldNames,CurrentMeasure); FieldnumsCategory = find(~cellfun('isempty',FieldnumsCategoryCell)); % Could do error checking here, since the next line is where this subfn usually errors % (if it can't find a FeatureName), but we ought to use 'try/catch' in the % calling function, for better error handling FeatureName = AllFieldNames(FieldnumsCategory(FeatureNumberOrName)); This works but it’s a hack, and I’m not sure if this bug affects other modules.


#4

Hi dkwood,

Thanks for your answer.
Actually, I made my own hack too, in CPgetfeaturenamesfromnumbers subfunction that is called at FilterByObjectMeasurement.m (line 119)

CPgetfeaturenamesfromnumbers.m - Line 50

...] elseif strcmp(Category,'Neighbors') || ... strcmp(Category,'Correlation') % added by myself Image = '';

I hope it doesn’t have a negative impact on other modules :confused:


#5

Hi p-j,

Yes, that was a bug on our part, and that is precisely the correction in CPgetfeaturenamesfromnumbers.m to make it work (though I’ll need to check whether it’s also correct for Category = ‘Correlation’ as well). Good catch!
-Mark


#6

Hi,

I have been having exactly this same problem, but I am not particularly Matlab profitient to fix it myself. Moreover, when I try to open the .m files, I can not read the text.

Can any of you give me the complete correct code for the cpgetfeaturesnamesfromnumber.m file? Would it work if I copy and paste this code into the actual file on cell profiler?

Thank you very much


#7

Hi,

You probably are looking at one of the compiled version’s files, which only have the help text in their .m files. You need to download the “Deverloper’s Version” of CellProfiler. This has the Matlab code you are looking for.

Also, we will be releasing a new version of Cellprofiler (with these fixes included) in the next few days, so you might best just wait until then to try all of this.

Best,
David