Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Bloc de code
languagejs
titleImageJ Macro to Equalize Brightness and Contrast for all opened images
collapsetrue
// 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

...

If all works fine you should have a CSV file you can open with your favourite favorite 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. Of course some measurements will be all the same because the images were taken in the same way.

What to do with the file? Explore the data and see if there is any relelvant infroamtionrelevant information.

My view would be to use a short script in R to plot all the data and to some basic statistics

...

Bloc de code
languageruby
titleScript R Merge CSV files and plot all data
collapsetrue

#Select the Input and the Output folder
Input <- "/Users/nicolas/Desktop/Input_Results-1/"
Output<-"/Users/nicolas/Desktop/Output/"
require("ggpubr")
#Get the list of CSV files
FileList<-list.files(path=Input, full.names=TRUE, pattern=".*csv")

#Merge the file into one big data
for (FileI in 1:length(FileList)){
  data<-read.csv(FileList[FileI])
  if (FileI==1){
    BigData<-data
  }else{
    BigData<-rbind(BigData,data)
  }
  
}
# then the rest is the same than the previous script
data<-BigData

List<-strsplit(as.character(data$Label), ':')

#Add Filename and Group to the data
data$Filename<-as.factor(sapply(List, "[[", 1))
Group<-strsplit(as.character(data$Filename), '_')
data$Group<-as.factor(sapply(Group, "[[", 1))
# Make Ch as a factor
data$Ch<-as.factor(data$Ch)

write.csv(data, paste0(Output,"ParticulesDetected-Cells_All -Measurements.csv"), row.names = FALSE)

#Create a list of plots
ListofPlots<-list()
i=1;

for(ColI in 3:(ncol(data)-2)){
  if(!is.factor(data[[ColI]])){
    for (ChI in 1:nlevels(data$Ch)){
   Graph<-   ggboxplot(
        data[data$Ch==ChI,], x = "Group", y = colnames(data[ColI]),
        color = "Group", palette = c("#4194fa", "#db51d4"),
        add = "jitter", title=paste0(colnames(data[ColI])," of Channel ", ChI)
      )+stat_compare_means(method = "t.test")
   ListofPlots[[i]]<-Graph
i=i+1
  }
  }
}

#Export the graphs
ggexport(
  plotlist = ListofPlots, filename = paste0(Output,"Graphs_individual.pdf"), 
  verbose=TRUE
)

...

This script will save the merged data in a single csv file. Usign your favourite spreadsheet manager you will be able to create a table and summarize the data with a pivot table to get the number of cells per group.


ControlTest
12251360

There are slighly more cells in the test than in the control. If we look at the number of detected cells per image we can confirm that there are more cells in the test conditions than in the control conditions. There are two images that have less celss than others in the control. We can go back to the detection to check those.

...

Looking at p-values (statistical significiance) only significance) is good approach but it is not enough. One We should also look at the biological sgnificiance significance of the numbers.For  For example the roundess is statiscially different between the control and test but this difference is really small. What does it mean biologically that the test cells are a tiny bit less circular. In this specific case : nothing much. So we can safely forget about it to focus on more important issue.things. 


This can easily be done since we have generated a CSV file gathering all the data Detected-Cells_All-Measurements.csv


Bloc de code
languageruby
titleR Script Create Graph with Descriptive Statistics
collapsetrue
# Prompt for the input CSV file from ImageJ measurements
Input<-file.choose()

# You must cange this path to match your computer
Output<-"/Users/nicolas/Desktop/Output/"

data<-read.csv(Input)

data$Ch<-as.factor(data$Ch)



require("ggpubr")
#Create a list of plots
ListofPlots<-list()
i=1;

for(ColI in 3:(ncol(data)-2)){
  if(is.numeric(data[[ColI]]) || is.integer(data[[ColI]])){
    for (ChI in 1:nlevels(data$Ch)){
      Graph<-ggsummarystats(
        data[data$Ch==ChI,], x = "Group", y=colnames(data[ColI]),
        ggfunc = ggviolin, digits = 2,
        color = "Group", palette = c("#4194fa", "#db51d4"),
        summaries=c("n", "mean","sd","ci"), add="mean_sd", title=paste0(colnames(data[ColI])," of Channel ", ChI))
      ListofPlots[[i]]<-Graph
      i=i+1
    }
  }
}

#Export the graphs
ggexport(
  plotlist = ListofPlots, filename = paste0(Output,"Graphs_Individual_Descriptive Stats.pdf"), 
  verbose=TRUE
)



Then for all the variables that are statically different between control and test groups we can have a closer look at the data.

  • Area Control 5.03um2 ; Test 5.35um2 p-value = 1.7e−07
    This is a relatively small increase 6%. If we bring this back to the diameter it is even smaller 3% increase. Yet the most relevant value in my view is the volume because cells are spheres in the real life. This increase is about a 10% increase in the cell volume. This is relevant information. Cells in the Test conditions are 10% bigger than in the control condition. 
  • Mean Ch2 Control 1078 GV; Test 1197 GV p-value < 2.2e−16
    This means that the bean shape structure labelled by Ch2 is 10% brighter in the test cells than in the controls. Yet the segmentation was performed on the full cell using Ch1 as a proxy. This result prompt for a segmentation based on Ch2. Are the bean shaped bigger or brighter? 
  • Min Ch2 Control 198 GV; Test 213 GV p-value 1e−05
    The difference in the minimum of Ch2 represent about 7.5% increase. If the minimum is higher it suggests that there is a global increase in the fluorescent of Ch2 and not a redistribution (ie clusterization). The segmentation on the Ch2 might sort out which option is really occurring
  • Max Ch1 Control 10111 GV; Test 8393 GV p-value < 2.2e−16
    This difference represent a 17% decrease of the maximum intensity of Ch1. If we remember Ch1 has two fluorescent levels, low within the nuclei and an intense foci. Here the maximum represent the Foci only. So we can conclude that the Foci are less intense in the test compare to the control.
  • Max Ch2 Control 3522 GV; Test 3761 GV p-value = 0.00035
    Here we have the opposite situation where in the bean shape structure the maximum intensity is higher in  the test condition than the control 
  • Perimeter Control 8.45um ; Test 8.74um p-value = 1.7e−08
    Here we have another measurement about the size of the detected cells. Using the area we can estimate about a 3.1% perimeter increase. Here the increase is about 3.5%. This is consistant meaning the increase in area and perimeter are about the same.
  • Width and Height Control 2.49um; Test 2.57um p-value = 8e−07
    Again here another measurement of the size of the detected cells which are larger in the test than the control
  • Major and Minor axis length Control 2.73um; Test 2.84um  p-value = 2.7e−10
    Similar to above excepted that instead of measuring the width and heigh of a rectangle around the cell it is an ellipse fitting the cell. In my view this would be more relevant variable than the previous one but since all data converge to slightly larger cells in the test than the control we can focus on the most interesting ones (area or perimeter)
  • Feret Control 2.95um; Test 3.05um p-value = 5.1e−10
    This is the maximum distance between two points of the detected cells. It relates to the shape of the cell
  • Integrated Density Ch1 Control 11296 GV; Test 11886 GV p-value
    This is the product of area and mean intensity. We know that the area is larger but not the mean intensity. Yet the integrated density of Ch1 is sligtlhy larger (5%) in test vs control.  
  • Integrated Density Ch2 Control 5570 GV; Test 6548 p-value < 2.2e−16
    Here we have a 17% increase which represent the combination of increase of cell size and mean intensity of Ch2
  • Skew of Ch1 Control 2.47; Test 1.77 p-value < 2.2e−16
    The skewness refers to the asymmetrical shape of the distribution of the intensities. Since values are above 0 it means that the distribution is skewed towards the higher intensities. Since this number is lower in the test cells, it means that the distribution of Ch1 intensity is less asymmetric. This can be easily explained by looking at Ch1 which has a low intensity within the nuclei and a strong foci. The foci high intensities provides a higher skew number. Since the skew is less closer to 0 in test conditions this could mean that the foci is less intense or that the fluorescence of Ch1 is more evenly distributed. Since we don't have an increase nor a decrease of mean intensity in Ch1 it is likely that the fluorescence is more evenly distributed in the test condition Thant the control. In other words it seems that in the control conditions the foci is brighter by taking some of the low fluorescence that is present in the nuclei. In other words, it seems that the test conditions can't make very bright foci and that the Ch1 fluorescence is more evenly distributed.
  • Kurt of Ch1 Control 11.3; Test 7.24 p-value < 2.2e−16
    The Kurt account for the flatness of the distribution. If Kurt=0 we have a normal distribution, if <0 it is flatter than normal; if >0 it is more peaked. In this case the data is very very peaked in both control and test. This is quite interesting especially when looking at the violin graphs below. In the control we can see 2 peaks one close to 0 and one close to 11. This means that there are two kinds of cells in the control condition, the one with a foci and the one with only low level distributed Ch1 fluorescence. In the test conditions the Kurt are entered and the two peaks are so close that they almost merged.


    View file
    nameKurt of Ch1.pdf
    height250
  • Raw Integrated density of Ch2 Control 313299 vs Test 368339; p-value < 2.2e−16
    This is the sum of the pixel intensities. It is higher in the test cell than the control cell. This can be because the intensity is higher and/or the area is larger. In this case we have seen previously that the area is larger. Interestingly Raw intensity is higher for Ch2 but is the same for Ch1. 

  • Roundness Control 0.84; Test 0.83 p-value = 0.0032
    As said before even though the value is significant the difference here is minimal and we can easily go to focus on another 


As we have seen here it seems that Ch1 and Ch2 have defined structrures that differs between the Control and test group. Our analysis looking at each cell does not provide enough detail on each structure. More specifically it can't discriminate between the low intensity Ch1 and the high intensity Foci. Also it looks at the overall fluorescence of Ch2 in the cell while we can clearly identify a bean shape structure. The next step would be to segment the images in 3 ways: high Ch1 intensities would correspond the the foci, high Ch2 intensities would correspond to the bean shape structure and low Ch1 intensities (all Ch1 intensities but excluding the high intensities from the Foci) would relate to the overall nuclei