Python code to measure the square area of colonies in an image file and export the data.
The heavy lifters are colSizeMeasurer.py and colSizeAnalyzer.py, but the input versions are more user-friendly and import the required functions.
Below are notes/instructions on how to use the user-friendly input files. The original data analysis files (colSizeMeasurer.py and colSizeAnalyzer.py) and the folders containing the data must be in the same folder as the input files for use.
Notes on colSizeMeasurer_input.py: The function to measure colony size will be called like below:
cm.measure(imFolder, imVector, imStrain, imPlate, imRepNum, imType, firstMask, secondMaskLow, secondMaskHigh, smallSize, largeSize, stdThreshold, results = True, manual = False, stdManual = .65)
Last three values are not necessarily needed because they have default values
imFolder: The folder name where the image file is located. Must be a string.
imVector: The vector name of the image. Must be a string.
imStrain: The strain name of the image. Must be a string.
imPlate: The resistance or the plate in the image. Must be a string.
imRepNum: The replicate number of the image. Must be a string.
imType: the image type used. Must be a string. Ex. '.png'
If any of these do not apply to your colony image just put NA. Image file datatype must be uint8.
Importing the image file: The image file must be named like this:
vector_strain_plate_repnumber.filetype
Cleaning up the image:
Large pixel intensity numbers have lighter intensities and small pixel intensity numbers have darker intensities. Change numbers as needed.
firstMask: A number that specifies the pixel intensity that will be masked. Every pixel with an intensity above this number will be removed (light pixels). *Filter makes the image uniform
secondMaskLow: A number that specifies the pixel intensity that will be masked. Every pixel with an intensity below this number will be removed (dark pixels).
secondMaskHigh: A number that specifies the pixel intensity that will be masked. Every pixel with an intensity above this number will be removed (light pixels). Should be more stringent(lower number) than the first mask.
smallSize: A number that specifies the size of small objects that will be removed. Every object with less pixels than this number will be removed.
largeSize: A number that specifies the size of large objects that will be removed. Every object with more pixels than this number will be removed.
stdThreshold: Number that specifies how symmetrical the colonies must be. The lower the number the more symmetrical the colonies must be. Unsymmetrical colonies are disposed of.
Measuring colony size:
results: Shows the images and analyzing step by step if True. If False, skips showing these things. default is True. Change as needed.
manual: allows you to manually include/skip outliers if True. Analyzes every colony that survives "clean up" if False. default is False. Change as needed.
stdManual: a number that specifies what an outlier is in the dataset. The number of standard deviations away from the median. Everything outside of that will be considered an outlier and will prompt you to decide whether or not to analyze it. A good number is 1 standard deviations which is the default. Change if you feel the need to.
Suggestions: Run this program with the image with your largest colonies and the image with your smallest colonies. Run with results as True and manual as False. Change the clean up values until the clean up is up to par. Take those optimized numbers and use the colSizeAnalyzer to analyze all your images processively with manual set to True.
Notes on colSizeAnalyzer_input.py: The class will be created like below:
colSizeAnalyzer = analyzer(Folders, imVectors, imStrains, imPlates, imRepNums, imType, firstMask, secondMaskLow, secondMaskHigh, smallSize, largeSize, stdThreshold, control)
Image file datatype must be uint8. checkFiletype quickly goes through all the image files and ensures they are uint8. If they are not, it throws an error.
Folders: The folder names where the image files are located. Must be a list.
imVectors: The vector names of the images. Must be a list.
imStrains: The strain names of the images. Must be a list.
imPlates: The resistance used or the plates in the images. Must be a list.
imRepNums: The replicate numbers of the images. Must be a list.
imType: the image type used. Must be a string. Ex. '.png'
If any of these do not apply to your colony images just put NA.
Importing the image files: The image files must be named like this:
vector_strain_plate_repnumber.filetype
Cleaning up the image:
Large pixel intensity numbers have lighter intensities and small pixel intensity numbers have darker intensities. Change numbers as needed.
firstMask: A number that specifies the pixel intesity that will be masked. Every pixel with an intensity above this number will be removed (light pixels). Filter makes the image uniform
secondMaskLow: A number that specifies the pixel intesity that will be masked. Every pixel with an intensity below this number will be removed (dark pixels).
secondMaskHigh: A number that specifies the pixel intesity that will be masked. Every pixel with an intensity above this number will be removed (light pixels). Should be more stringent(lower number) than the first mask.
smallSize: A number that specifies the size of small objects that will be removed. Every object with less pixels than this number will be removed.
largeSize: A number that specifies the size of large objects that will be removed. Every object with more pixels than this number will be removed.
stdThreshold: Number that specifies how symmetrical the colonies must be. The lower the number the more symmetrical the colonies must be. Unsymmetrical colonies are disposed of.
Measuring colony size:
control: the vector, strain, and plate of the control. Used to make the size ratio. Must be a list.
Ex.
control = ['pJHAPAOrn', 'dOrn', 'Gm']
Make and Export the data: Method will be used like below:
makeData(exportNameSum, exportNameRaw, listRawData)
exportNameSum: the export name of the excel file that will have the summary data
exportNameRaw: the export name of the excel file that will have the raw data
listRawData: list of all the raw data. Must be a list. if only one dataset in list it will export that one dataset. if more than one data set it will combine the datasets then export them.
Suggestions: Run the colSizeMeasurer program with the image with your largest colonies and the image with your smallest colonies. Run the colSizeMeasurer with results as True and manual as False. Change the clean up values until the clean up is up to par. Take those optimized numbers and use this program to analyze all your images processively.