...
Bloc de code | ||||||
---|---|---|---|---|---|---|
| ||||||
// This macro was created by nstifani@gmail.com // Feel free to reach out for any question or improvement suggestions // This macro will look for Min and Max values on all open images and then apply the Min and the Max to adjust the display brightness of all opened images. // Create Arrays to store image info ListOfCh=newArray(nImages); ListOfSlices=newArray(nImages); ListOfFrames=newArray(nImages); // Get the dimensions of the opened Images for(ImageI=1; ImageI<nImages+1; ImageI++){ selectImage(ImageI); getDimensions(width, height, channels, slices, frames); ListOfCh[ImageI-1]=channels; ListOfSlices[ImageI-1]=slices; ListOfFrames[ImageI-1]=frames; }// end for ImageI // Get some statistics Array.getStatistics(ListOfCh, MinCh, MaxCh, MeanCh, StdDevCh); Array.getStatistics(ListOfSlices, MinSlice, MaxSlice, MeanSlice, StdDevSlice); Array.getStatistics(ListOfFrames, MinFrame, MaxFrame, MeanFrame, StdDevFrame); // Process all chanels using two functions for(ChI=1; ChI<MaxCh+1;ChI++){ MinAndMax=GetBnCValues(ChI); MinMin=MinAndMax[0]; MaxMax=MinAndMax[1]; ApplyBnC(ChI,MinMin, MaxMax); } function GetBnCValues(ChI) { ListOfMin=newArray(nImages); ListOfMax=newArray(nImages); // Measure Min and Max for all open images for(ImageI=1; ImageI<nImages+1; ImageI++){ selectImage(ImageI); Stack.setChannel(ChI); resetMinAndMax(); run("Enhance Contrast", "saturated=0.35"); getMinAndMax(min, max); ListOfMin[ImageI-1]=min; ListOfMax[ImageI-1]=max; }// end for ImageI // Get Statistics Array.getStatistics(ListOfMin, MinMin, MaxMin, MeanMin, StdDevMin); Array.getStatistics(ListOfMax, MinMax, MaxMax, MeanMax, StdDevMax); return newArray(MinMin, MaxMax); } function ApplyBnC(ChI, MinMin, MaxMax) { for(ImageI=1; ImageI<nImages+1; ImageI++){ selectImage(ImageI); Stack.setChannel(ChI); setMinAndMax(MinMin, MaxMax); }// end for ImageI |
...
Control Ch1 Control Ch2
If you apply the same display to Ch1 and Ch2 then you can see that Ch1 overall more intense while Ch2 has few very strong spots.
Control Control Ch1 Control Ch2 with same display than Ch1
...
In Ch1 we can see that there is some low level intensity and a high level circular foci whereas in Ch2 there is a bean shaped structure.
Control Ch1 Control Ch2
In the example below the Foci seems stronger in the control than the Test condition.
Control Ch1 Test Ch1
Control Ch2 Test Ch2
But we need obviously to do some quantification to confirm or infirm these first observations.
The first way to address it would be in a bulk fashion: By measuring the mean intensity for example for all the images.
Bloc de code | ||||||
---|---|---|---|---|---|---|
| ||||||
//It might be easier to process images from a folder
//You would need to customize this path to your computer
InputDir="/Users/nicolas/Desktop/Input/";
// You could also get a prompt to select the InputDir
// InputDir = getDirectory("Choose a Directory ");
// And to save results in an output folder
// You would need to customize this path to your computer
//OutputPath="/Users/nicolas/Desktop/Output/";
//You could also create a new folder based on the name of the input folder
ParentPath=File.getParent(InputDir);
InputDirName=File.getName(InputDir);
OutputDir=ParentPath+File.separator+InputDirName+"_Results";
i=1;
while(File.exists(OutputDir)){
OutputDir=ParentPath+File.separator+InputDirName+"_Results"+"-"+i;
i++;
}
File.makeDirectory(OutputDir);
OutputPath=OutputDir+File.separator;
//Then you can measure all values for all ch and all images
ListFile=getFileList(InputDir);
run("Set Measurements...", "area mean standard modal min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack display redirect=None decimal=3");
run("Clear Results");
// It might be faster to work in batchmdoe
setBatchMode(true);
for (Filei=0; Filei<ListFile.length; Filei++){
FilePath=InputDir+ListFile[Filei];
open(FilePath);
ImageName=getTitle();
selectWindow(ImageName);
run("Select None");
run("Measure Stack...");
selectWindow(ImageName); run("Close");
}
selectWindow("Results");
saveAs("Text", OutputPath+"Overall_Measurements.csv");
selectWindow("Results"); run("Close");
|
If all works fine you should have a csv file you can open with your favourite spreadsheet applications. This table should give one line per image and all available measurements for the whole image and for each channel of the image.