OverflowError: cannot convert float infinity to integer


#1

I’m getting the following error:

Traceback (most recent call last):
  File "cellprofiler\pipeline.pyc", line 1934, in run_image_set
  File "cellprofiler\modules\identifyprimaryobjects.pyc", line 898, in run
  File "cellprofiler\modules\identify.pyc", line 754, in threshold_image
  File "cellprofiler\modules\identify.pyc", line 872, in get_threshold
  File "cellprofiler\cpmath\threshold.pyc", line 147, in get_threshold
  File "cellprofiler\cpmath\threshold.pyc", line 268, in get_adaptive_threshold
OverflowError: cannot convert float infinity to integer

The overflow error appears very often, on two different computer running the same pipeline.

CellProfiler_Version	2014-07-23T17:45:00 6c2d896
ChannelType_mask	Grayscale
ChannelType_raw	Color
ImageSet_Zip_Dictionary	"[ 32  73  34  32  73  68  61  34  32  70 105 114 115 116  34  48  34  32
  70 105 114 115 116  32  34  62  60  80 105 120 101 108 115  32  68 105
 109 101 110 115 105 111 110  79 114 100 101 114  61  34  88  89  67  90
  84  34  32  73  68  61  34  80 105 120 101 108 115  58  34  32  83 105
 122 101  84  61  34  49  34  32  83 105 122 101  88  61  34  49  34  32
  83 105 122 101  89  61  34  49  34  62  60  84 105 102 102  68  97 116
  97  32  70 105 114 115 116  67  61  34  48  34  32  70 105 114 115 116
  84  61  34  48  34  32  70 105 114 115 116  90  61  34  48  34  32  73
  70  68  61  34  48  34  32  80 108  97 110 101  67 111 117 110 116  61
  34  49  34  62  60  85  85  73  68  32  70 105 108 101  78  97 109 101
  61  34 102 105 108 101  58  47  47  47  67  58  47  85 115 101 114 115
  47  78 105 107 111 108  99 101  47  71 111 111 103 108 101  37  50  48
  68 114 105 118 101  47  75  73  47  77  84  47  73 109  97 103 101 115
  37  50  48  67  80  37  50  48  79 112 116 105 109 105 115  97 116 105
 111 110  47  80  50  52  45 112 105 110 107  95  67  83  95  46 106 112
 103  34  47  62  60  47  84 105 102 102  68  97 116  97  62  60  80 108
  97 110 101  32  84 104 101  67  61  34  48  34  32  84 104 101  84  61
  34  48  34  32  84 104 101  90  61  34  48  34  47  62  60  47  80 105
 120 101 108 115  62  60  47  73 109  97 103 101  62  60]"
Metadata_Tags	"[""ImageNumber""]"
Pipeline_Pipeline	"CellProfiler Pipeline: http://www.cellprofiler.org
Version:3
DateRevision:20140723174500
GitHash:6c2d896
ModuleCount:14
HasImagePlaneDetails:False

Images:[module_num:1|svn_version:\'Unknown\'|variable_revision_number:2|show_window:False|notes:\x5B\'To begin creating your project, use the Images module to compile a list of files and/or folders that you want to analyze. You can also specify a set of rules to include only the desired files in your selected folders.\'\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    :
    Filter images?:Images only
    Select the rule criteria:and (extension does isimage) (directory doesnot containregexp ""\x5B\\\\\\\\\\\\\\\\/\x5D\\\\\\\\."")

Metadata:[module_num:2|svn_version:\'Unknown\'|variable_revision_number:4|show_window:False|notes:\x5B\'The Metadata module optionally allows you to extract information describing your images (i.e, metadata) which will be stored along with your measurements. This information can be contained in the file name and/or location, or in an external file.\'\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Extract metadata?:Yes
    Metadata data type:Text
    Metadata types:{}
    Extraction method count:1
    Metadata extraction method:Extract from file/folder names
    Metadata source:File name
    Regular expression:^(?P<Patient>.*)_(?P<Antibody>.*)_(?P<Type>.*)_(?P<Segment>.*)_(?P<Picture>.*).jpg
    Regular expression:(?P<Date>\x5B0-9\x5D{4}_\x5B0-9\x5D{2}_\x5B0-9\x5D{2})$
    Extract metadata from:All images
    Select the filtering criteria:and (file does contain """")
    Metadata file location:
    Match file and image metadata:\x5B\x5D
    Use case insensitive matching?:No

NamesAndTypes:[module_num:3|svn_version:\'Unknown\'|variable_revision_number:5|show_window:False|notes:\x5B\'The NamesAndTypes module allows you to assign a meaningful name to each image by which other modules will refer to it.\'\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Assign a name to:Images matching rules
    Select the image type:Color image
    Name to assign these images:raw
    Match metadata:\x5B\x5D
    Image set matching method:Order
    Set intensity range from:Image metadata
    Assignments count:2
    Single images count:0
    Select the rule criteria:and (file doesnot contain ""mask"")
    Name to assign these images:raw
    Name to assign these objects:Cell
    Select the image type:Color image
    Set intensity range from:Image metadata
    Retain outlines of loaded objects?:No
    Name the outline image:LoadedOutlines
    Select the rule criteria:and (file does contain ""mask"")
    Name to assign these images:mask
    Name to assign these objects:Nucleus
    Select the image type:Grayscale image
    Set intensity range from:Image metadata
    Retain outlines of loaded objects?:No
    Name the outline image:LoadedOutlines

Groups:[module_num:4|svn_version:\'Unknown\'|variable_revision_number:2|show_window:False|notes:\x5B\'The Groups module optionally allows you to split your list of images into image subsets (groups) which will be processed independently of each other. Examples of groupings include screening batches, microtiter plates, time-lapse movies, etc.\'\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Do you want to group your images?:No
    grouping metadata count:1
    Metadata category:None

UnmixColors:[module_num:5|svn_version:\'Unknown\'|variable_revision_number:2|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Stain count:2
    Select the input color image:raw
    Name the output name:DAB
    Stain:Custom
    Red absorbance:0.367762
    Green absorbance:0.604443
    Blue absorbance:0.706682
    Name the output name:Hematoxylin
    Stain:Custom
    Red absorbance:0.51545
    Green absorbance:0.777032
    Blue absorbance:0.361294

MaskImage:[module_num:6|svn_version:\'Unknown\'|variable_revision_number:3|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Select the input image:DAB
    Name the output image:test
    Use objects or an image as a mask?:Image
    Select object for mask:None
    Select image for mask:mask
    Invert the mask?:No

IdentifyPrimaryObjects:[module_num:7|svn_version:\'Unknown\'|variable_revision_number:10|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Select the input image:test
    Name the primary objects to be identified:DAB_regions
    Typical diameter of objects, in pixel units (Min,Max):10,8000
    Discard objects outside the diameter range?:Yes
    Try to merge too small objects with nearby larger objects?:No
    Discard objects touching the border of the image?:No
    Method to distinguish clumped objects:None
    Method to draw dividing lines between clumped objects:None
    Size of smoothing filter:2
    Suppress local maxima that are closer than this minimum allowed distance:3
    Speed up by using lower-resolution image to find local maxima?:No
    Name the outline image:DAB_outlines
    Fill holes in identified objects?:Never
    Automatically calculate size of smoothing filter for declumping?:Yes
    Automatically calculate minimum allowed distance between local maxima?:Yes
    Retain outlines of the identified objects?:Yes
    Automatically calculate the threshold using the Otsu method?:Yes
    Enter Laplacian of Gaussian threshold:0.5
    Automatically calculate the size of objects for the Laplacian of Gaussian filter?:Yes
    Enter LoG filter diameter:5.0
    Handling of objects if excessive number of objects identified:Continue
    Maximum number of objects:500
    Threshold setting version:1
    Threshold strategy:Adaptive
    Thresholding method:Otsu
    Select the smoothing method for thresholding:Automatic
    Threshold smoothing scale:1
    Threshold correction factor:1
    Lower and upper bounds on threshold:0.2,0.6
    Approximate fraction of image covered by objects?:0.01
    Manual threshold:0.25
    Select the measurement to threshold with:None
    Select binary image:None
    Masking objects:None
    Two-class or three-class thresholding?:Two classes
    Minimize the weighted variance or the entropy?:Weighted variance
    Assign pixels in the middle intensity class to the foreground or the background?:Foreground
    Method to calculate adaptive window size:Image size
    Size of adaptive window:10

IdentifyPrimaryObjects:[module_num:8|svn_version:\'Unknown\'|variable_revision_number:10|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Select the input image:Hematoxylin
    Name the primary objects to be identified:Nuclei
    Typical diameter of objects, in pixel units (Min,Max):10,100
    Discard objects outside the diameter range?:Yes
    Try to merge too small objects with nearby larger objects?:No
    Discard objects touching the border of the image?:No
    Method to distinguish clumped objects:None
    Method to draw dividing lines between clumped objects:Shape
    Size of smoothing filter:3
    Suppress local maxima that are closer than this minimum allowed distance:20
    Speed up by using lower-resolution image to find local maxima?:Yes
    Name the outline image:nuclei_outlines
    Fill holes in identified objects?:After both thresholding and declumping
    Automatically calculate size of smoothing filter for declumping?:No
    Automatically calculate minimum allowed distance between local maxima?:No
    Retain outlines of the identified objects?:Yes
    Automatically calculate the threshold using the Otsu method?:Yes
    Enter Laplacian of Gaussian threshold:0.5
    Automatically calculate the size of objects for the Laplacian of Gaussian filter?:Yes
    Enter LoG filter diameter:5.0
    Handling of objects if excessive number of objects identified:Continue
    Maximum number of objects:500
    Threshold setting version:1
    Threshold strategy:Global
    Thresholding method:Otsu
    Select the smoothing method for thresholding:Automatic
    Threshold smoothing scale:1.0
    Threshold correction factor:1
    Lower and upper bounds on threshold:0.50,1.0
    Approximate fraction of image covered by objects?:0.01
    Manual threshold:0.20
    Select the measurement to threshold with:None
    Select binary image:None
    Masking objects:None
    Two-class or three-class thresholding?:Two classes
    Minimize the weighted variance or the entropy?:Weighted variance
    Assign pixels in the middle intensity class to the foreground or the background?:Foreground
    Method to calculate adaptive window size:Image size
    Size of adaptive window:10

MeasureImageAreaOccupied:[module_num:9|svn_version:\'Unknown\'|variable_revision_number:3|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Hidden:1
    Measure the area occupied in a binary image, or in objects?:Objects
    Select objects to measure:DAB_regions
    Retain a binary image of the object regions?:No
    Name the output binary image:binary
    Select a binary image to measure:mask

MeasureImageIntensity:[module_num:10|svn_version:\'Unknown\'|variable_revision_number:2|show_window:True|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Select the image to measure:test
    Measure the intensity only from areas enclosed by objects?:Yes
    Select the input objects:DAB_regions
    Select the image to measure:Hematoxylin
    Measure the intensity only from areas enclosed by objects?:Yes
    Select the input objects:Nuclei

MeasureObjectIntensity:[module_num:11|svn_version:\'Unknown\'|variable_revision_number:3|show_window:True|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Hidden:1
    Select an image to measure:test
    Select objects to measure:Nuclei

OverlayOutlines:[module_num:12|svn_version:\'Unknown\'|variable_revision_number:3|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Display outlines on a blank image?:No
    Select image on which to display outlines:raw
    Name the output image:OrigOverlay
    Outline display mode:Color
    Select method to determine brightness of outlines:Max of image
    Width of outlines:0.3
    Select outlines to display:DAB_outlines
    Select outline color:red
    Load outlines from an image or objects?:Image
    Select objects to display:None
    Select outlines to display:None
    Select outline color:green
    Load outlines from an image or objects?:Objects
    Select objects to display:Nuclei

SaveImages:[module_num:13|svn_version:\'Unknown\'|variable_revision_number:11|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Select the type of image to save:Image
    Select the image to save:OrigOverlay
    Select the objects to save:None
    Select the module display window to save:None
    Select method for constructing file names:From image filename
    Select image name for file prefix:raw
    Enter single file name:OrigBlue
    Number of digits:4
    Append a suffix to the image file name?:Yes
    Text to append to the image name:_outlines
    Saved file format:jpeg

    Image bit depth:8
    Overwrite existing files without warning?:Yes
    When to save:Every cycle
    Rescale the images? :No
    Save as grayscale or color image?:Grayscale
    Select colormap:Default
    Record the file and path information to the saved image?:No
    Create subfolders in the output folder?:No
    Base image folder:Elsewhere...\x7C
    Saved movie format:avi

ExportToSpreadsheet:[module_num:14|svn_version:\'Unknown\'|variable_revision_number:11|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]
    Select the column delimiter:Tab
    Add image metadata columns to your object data file?:Yes
    Limit output to a size that is allowed in Excel?:No
    Select the measurements to export:Yes
    Calculate the per-image mean values for object measurements?:Yes
    Calculate the per-image median values for object measurements?:Yes
    Calculate the per-image standard deviation values for object measurements?:Yes
    Output file location:Default Input Folder sub-folder\x7CDesktop
    Create a GenePattern GCT file?:No
    Select source of sample row name:Metadata
    Select the image to use as the identifier:None
    Select the metadata to use as the identifier:None
    Export all measurement types?:Yes
    Press button to select measurements to export:DAB_regions\x7CLocation_Center_Y,DAB_regions\x7CLocation_Center_X,DAB_regions\x7CNumber_Object_Number,Image\x7CCount_Nuclei,Image\x7CCount_DAB_regions,Image\x7CAreaOccupied_Perimeter_DAB_regions,Image\x7CAreaOccupied_TotalArea_DAB_regions,Image\x7CAreaOccupied_AreaOccupied_DAB_regions,Image\x7CWidth_mask,Image\x7CWidth_raw,Image\x7CHeight_mask,Image\x7CHeight_raw,Image\x7CIntensity_StdIntensity_test_DAB_regions,Image\x7CIntensity_StdIntensity_Hematoxylin_Nuclei,Image\x7CIntensity_TotalIntensity_test_DAB_regions,Image\x7CIntensity_TotalIntensity_Hematoxylin_Nuclei,Image\x7CIntensity_TotalArea_test_DAB_regions,Image\x7CIntensity_TotalArea_Hematoxylin_Nuclei,Image\x7CIntensity_MeanIntensity_test_DAB_regions,Image\x7CIntensity_MeanIntensity_Hematoxylin_Nuclei,Image\x7CFileName_raw,Image\x7CFileName_mask,Image\x7CMetadata_Antibody,Image\x7CMetadata_Picture,Image\x7CMetadata_FileLocation,Image\x7CMetadata_Type,Image\x7CMetadata_Frame,Image\x7CMetadata_Series,Image\x7CMetadata_Patient,Image\x7CMetadata_Segment,Experiment\x7CRun_Timestamp,Experiment\x7CPipeline_Pipeline,Nuclei\x7CIntensity_MassDisplacement_test,Nuclei\x7CIntensity_MinIntensity_test,Nuclei\x7CIntensity_IntegratedIntensityEdge_test,Nuclei\x7CIntensity_StdIntensity_test,Nuclei\x7CIntensity_UpperQuartileIntensity_test,Nuclei\x7CIntensity_IntegratedIntensity_test,Nuclei\x7CIntensity_MinIntensityEdge_test,Nuclei\x7CIntensity_MADIntensity_test,Nuclei\x7CIntensity_MeanIntensity_test,Nuclei\x7CIntensity_MeanIntensityEdge_test,Nuclei\x7CIntensity_LowerQuartileIntensity_test,Nuclei\x7CIntensity_MaxIntensity_test,Nuclei\x7CIntensity_MedianIntensity_test,Nuclei\x7CIntensity_StdIntensityEdge_test,Nuclei\x7CIntensity_MaxIntensityEdge_test,Nuclei\x7CNumber_Object_Number
    Representation of Nan/Inf:NaN
    Add a prefix to file names?:No
    Filename prefix\x3A:MyExpt_
    Overwrite without warning?:No
    Data to export:Do not use
    Combine these object measurements with those of the previous object?:No
    File name:DATA.csv
    Use the object name for the file name?:Yes
"

#2

Does it always occur on the same image(s), and if so can you post a set of images that reproduces the error along with a .cppipe file with that pipeline?

I’d be curious to see if manually setting the adaptive window size (rather than letting the program try to calculate it) would avoid the error.


#3

I have not really thought about if it occurs when analysing specific images, but I’ll keep an eye out for whenever it happens.

What actually causes this particular error? I usually press continue processing, but I’m not really sure how this error might impact my results.


#4

What actually causes this particular error? I usually press continue processing, but I’m not really sure how this error might impact my results.

I’m not actually sure, which is why I was hoping to see if there are images where it reliably does and does not happen that we could compare.
My suspicion is that it’s because you’re using an adaptive threshold window on masked images; in areas where there are only masks, it might be trying to calculate a local threshold and failing because all the pixels are masked out. If that is what’s actually happening, it’s probably something that needs to be fixed in the code, but if you’re actually getting output from your pipeline it’s hopefully not fatal to your current workflow.