Author: Antonetta Brigitte Cornelia Buskermolen, 2017-2018
Copyright: University of Technology Eindhoven 2018

ClearAll["Global`*"]
$HistoryLength=1;
ClearSystemCache[];

Declare variables:

In factor you can change the # um/pixel, which depends on the type of microscope and objective you use.

GraphicsGrid[{{Button["10xaxio",factor=1.059],Button["20xaxio",factor=0.53],Button["40xaxio",factor=0.266],Button["100xaxio",factor=0.105]}}]

Import images one map:

In dir you can put the folder of interest, in this particular example we extract the data from all the merged images (=imagestotal),
images of the actin cytoskeleton (=imagesactin), nucleus =(imagesnucleus), and focal adhesions (=imagesfocaladhesions).

dir="C:\\Users\\abuskerm\\Desktop\\Immunofluorescence\\Image Analysis\\Test programma";
files=FileNames["*.tif",dir];
numberoffiles=Length[files];
alldata=Table[Import[files[[j]]],{j,1,numberoffiles}];
numberofpositions=Length[files]/4;
imagesactin=Table[alldata[[2+((i-1)*4)]],{i,1,numberofpositions}]
imagesnucleus=Table[alldata[[3+((i-1)*4)]],{i,1,numberofpositions}]
imagesfocal=Table[alldata[[4+((i-1)*4)]],{i,1,numberofpositions}]
imagestotal=Table[alldata[[1+((i-1)*4)]],{i,1,numberofpositions}];

Remove background and adjust image:

This part is used to remove the background from the images.

transformactin=ImageAdjust[#]&/@imagesactin;
transformnucleus=ImageAdjust[#]&/@imagesnucleus;

removebackgroundactin=TopHatTransform[#,150]&/@transformactin;
removebackgroundnucleus=TopHatTransform[#,100]&/@transformnucleus;

tophattransformfocal=TopHatTransform[#,DiskMatrix[40]]&/@imagesfocal;
Medianfilterred7=MedianFilter[#,7]&/@tophattransformfocal
removebackground7=Image[ImageData[#[[1]]]-ImageData[#[[2]]]]&/@Transpose[{tophattransformfocal,Medianfilterred7}];

actinadjusted=removebackgroundactin;
nucleusadjusted=removebackgroundnucleus;
focaladjusted=removebackground7;

Binarize images:

This part is used to binarize the images.

binblue=Binarize[Erosion[FillingTransform[Dilation[#,1]],1]]&/@nucleusadjusted;
binactin=DeleteSmallComponents[MorphologicalBinarize[Erosion[FillingTransform[Dilation[#,1]],1]],Method->"Mean"]&/@ actinadjusted;

quantifyfocal7=Binarize[#]&/@removebackground7;
imageadhesions7=Colorize[MorphologicalComponents[#]]&/@quantifyfocal7;
composefocal=ImageCompose[#[[1]],RemoveBackground[#[[2]]]]&/@Transpose[{imagesfocal,imageadhesions7}]

Crop images:

You can use this part to crop the images, when you have a border surrounding the images. In border you can change the number of pixels you want to remove from the images.

border=5;
Crop[img_,{{dxl_,dxr_},{dyl_,dyu_}}]:=ImageTake[img,{dyl,-dyu},{dxl,-dxr}]
actincrop=Crop[#,{{border,border},{border,border}}]&/@binactin
cellcrop=Crop[#,{{border,border},{border,border}}]&/@actinadjusted
nucleuscrop=Crop[#,{{border,border},{border,border}}]&/@binblue
focalcrop=Crop[#,{{border,border},{border,border}}]&/@quantifyfocal7;

Multiple cells:

This part is used for the analysis of multiple cells per image. To only analyze individual cells, which are not touching the image border,  
we first need to segment all the cells in individual cells (based on watershed segmentation). For this we use the command markergreenselect,
 where you can adjust the number to find the correct markers for segmentation. In areacell  you can change the number to remove small objects that fail the size criterion to be a single cell (objects smaller than 20 µm^2)

marker=0.15;
areacell=20/(factor^2);
disTgreenselect=ImageAdjust[DistanceTransform[#]]&/@actincrop;
markergreenselect=MaxDetect[#,marker]&/@disTgreenselect
watershedComponentsgreenselect=WatershedComponents[ColorNegate[#[[1]]],#[[2]]]*ImageData[#[[3]]]&/@Transpose[{disTgreenselect,markergreenselect,actincrop}];
imageselect=Colorize[#]&/@watershedComponentsgreenselect

selectallactin=imageselect;
selectactinnocolour=Binarize[#]&/@selectallactin;
selectactinold=SelectComponents[#,"AdjacentBorderCount",#==0&]&/@selectactinnocolour;
selectactin=SelectComponents[#,"Area",areacell/(factor^2)<#&]&/@selectactinold
selectcell=ImageMultiply[#[[1]],#[[2]]]&/@Transpose[{cellcrop,selectactin}]
selectnucleus=FillingTransform[ImageMultiply[#[[1]],#[[2]]]]&/@Transpose[{nucleuscrop,selectactin}]
selectfocal=FillingTransform[ImageMultiply[#[[1]],#[[2]]]]&/@Transpose[{focalcrop,selectactin}]

Data analysis multiple cells:

Nucleus:

This part is used to quantify the different properties from the nucleus, such as the elongation, orientation, area, etc. To only select individual nuclei and 
not some small background dots or multiple nuclei, you can use the command markerblue (0<markerblue<1). Increase the number when you don’t want to include small background dots, decrease the number when multiple nuclei are detected as one.

selectimagenucleus=SelectComponents[#,"Area",#>200&]&/@selectnucleus
disTblue=DistanceTransform[#]&/@selectimagenucleus;
markerblue=MaxDetect[#,5]&/@disTblue;
watershedComponentsblue=WatershedComponents[ColorNegate[#[[1]]],#[[2]]]*ImageData[#[[3]]]&/@Transpose[{disTblue,markerblue,selectimagenucleus}];
imagenucleus=Colorize[#]&/@watershedComponentsblue
componentsblue=ComponentMeasurements[{#[[1]],#[[2]]},{"Centroid","SemiAxes","Orientation","Max"}]&/@Transpose[{watershedComponentsblue,disTblue}];
componentsbluelongaxis=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Length"}]&/@Transpose[{watershedComponentsblue,disTblue}]/.Rule[a_,b_]->b*factor];
componentsblueshortaxis=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Width"}]&/@Transpose[{watershedComponentsblue,disTblue}]/.Rule[a_,b_]->b*factor];
componentsblueelongation=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Elongation"}]&/@Transpose[{watershedComponentsblue,disTblue}]/.Rule[a_,b_]->b];
componentsbluearea=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Area"}]&/@Transpose[{watershedComponentsblue,disTblue}]/.Rule[a_,b_]->b*(factor^2)];
componentsblueperimeter=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"PolygonalLength"}]&/@Transpose[{watershedComponentsblue,disTblue}]/.Rule[a_,b_]->b*factor];
componentsblueangle=(180/Pi)*Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Orientation"}]&/@Transpose[{watershedComponentsblue,disTblue}]/.Rule[a_,b_]->b];
componentsblueangle2=If[#<0,180-Abs[#],#]&/@componentsblueangle;
fitellipsenucleus=Show[#[[1]],Graphics[{Red,#[[2]][[All,2]]/.{{centroid_,semiAxes_,orientation_,maxR_}:>Rotate[Disk[centroid,{semiAxes[[1]],semiAxes[[2]]}],orientation,centroid]}}]]&/@Transpose[{selectnucleus,componentsblue}]
outlinenucleus=EdgeDetect[#]&/@selectnucleus

Cells:

This parts can be used to quantify different properties from all the detected cells, such as the elongation, orientation, area. To  only select individual cells, you can use the command markergreen (0<markergreen<1). Increase the number when you oversegmented the cells , decrease the number when multiple cells are detected as one.

disTgreen=ImageAdjust[DistanceTransform[#]]&/@selectactin
markergreen=MaxDetect[#,0.3]&/@disTgreen
watershedComponentsgreen=WatershedComponents[ColorNegate[#[[1]]],#[[2]]]*ImageData[#[[3]]]&/@Transpose[{disTgreen,markergreen,selectactin}];
image=Colorize[#]&/@watershedComponentsgreen
componentsgreen=ComponentMeasurements[{#[[1]],#[[2]]},{"Centroid","SemiAxes","Orientation","Max"}]&/@Transpose[{watershedComponentsgreen,disTgreen}];
componentsgreenlongaxis=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Length"}]&/@Transpose[{watershedComponentsgreen,disTgreen}]/.Rule[a_,b_]->b*factor];
componentsgreenshortaxis=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Width"}]&/@Transpose[{watershedComponentsgreen,disTgreen}]/.Rule[a_,b_]->b*factor];
componentsgreenelongation=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Elongation"}]&/@Transpose[{watershedComponentsgreen,disTgreen}]/.Rule[a_,b_]->b];
componentsgreenarea=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Area"}]&/@Transpose[{watershedComponentsgreen,disTgreen}]/.Rule[a_,b_]->b*(factor^2)];
componentsgreenperimeter=Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"PolygonalLength"}]&/@Transpose[{watershedComponentsgreen,disTgreen}]/.Rule[a_,b_]->b*factor];
componentsgreenangle=(180/Pi)*Flatten[ComponentMeasurements[{#[[1]],#[[2]]},{"Orientation"}]&/@Transpose[{watershedComponentsgreen,disTgreen}]/.Rule[a_,b_]->b];
componentsgreenangle2=If[#<0,180-Abs[#],#]&/@componentsgreenangle;
Lengthcell=Flatten[ComponentMeasurements[#,"CaliperLength"]&/@watershedComponentsgreen/.Rule[a_,b_]->b*factor];
fitellipseactin=Show[#[[1]],Graphics[{Red,#[[2]][[All,2]]/.{{centroid_,semiAxes_,orientation_,maxR_}:>Rotate[Disk[centroid,{semiAxes[[1]],semiAxes[[2]]}],orientation,centroid]}}]]&/@Transpose[{selectactin,componentsgreen}]
outlinecell=EdgeDetect[#]&/@selectactin

Focal adhesions:

This part can be used to quantify the different properties from the focal adhesions of multiple, such as the elongation, orientation, area, etc. FAs smaller than 0.1 um^2 (size can be adjusted in sizefocal) are excluded to 
ensure that background noise is eliminated from the analysis.

sizefocal=0.1;
selectfocalareanew=SelectComponents[#, "Area",sizefocal/(factor^2)<#&]&/@selectfocal
shortaxisfocal=Flatten[ComponentMeasurements[#,"Width"]]&/@selectfocalareanew/.Rule[a_,b_]->b*factor;
longaxisfocal=Flatten[ComponentMeasurements[#,"Length"]]&/@selectfocalareanew/.Rule[a_,b_]->b*factor;
centroidfocal=Flatten[ComponentMeasurements[#,"Centroid"]]&/@selectfocalareanew/.Rule[a_,b_]->b;
elongationfocal=Flatten[ComponentMeasurements[#,"Elongation"]]&/@selectfocalareanew/.Rule[a_,b_]->b;
lengthfocal=Flatten[ComponentMeasurements[#,"CaliperLength"]]&/@selectfocalareanew/.Rule[a_,b_]->b*factor;
perimeterfocal=Flatten[ComponentMeasurements[#,"PolygonalLength"]]&/@selectfocalareanew/.Rule[a_,b_]->b*factor;
Areafocalafter=Flatten[ComponentMeasurements[#, "Area"]]&/@selectfocalareanew/.Rule[a_,b_]->b*(factor^2);
Orientationfocal=(180/Pi)*Flatten[ComponentMeasurements[#, "Orientation"]]&/@selectfocalareanew/.Rule[a_,b_]->b;
Orientationfocal2=If[#<0,180-Abs[#],#]&/@Orientationfocal;
fitellipsefocal=ComponentMeasurements[#,{"Centroid","SemiAxes","Orientation","Max"}]&/@selectfocalareanew;
Show[#[[1]],Graphics[{Red,#[[2]][[All,2]]/.{{centroid_,semiAxes_,orientation_,maxR_}:>Rotate[Disk[centroid,{semiAxes[[1]],semiAxes[[2]]}],orientation,centroid]}}]]&/@Transpose[{selectfocalareanew,fitellipsefocal}]

Export:

This part can be used to export the images of the detected cells, nuclei and focal adhesions and outlines of the cells and nuclei.
The extracted data from these cells, nuclei and focal adhesions are exported to an excel file.

SetDirectory[dir];
Do[Export[StringJoin["selectactin_",ToString[n],".tif"],selectactin[[n]]],{n,1,Length[selectactin]}]
Do[Export[StringJoin["selectnucleus_",ToString[n],".tif"],selectnucleus[[n]]],{n,1,Length[selectnucleus]}]
Do[Export[StringJoin["watershedactin_",ToString[n],".tif"],image[[n]]],{n,1,Length[image]}]
Do[Export[StringJoin["selectcell_",ToString[n],".tif"],selectcell[[n]]],{n,1,Length[selectcell]}]
Do[Export[StringJoin["celloutlinenew_",ToString[n],".tif"],outlinecell[[n]]],{n,1,Length[outlinecell]}]
Do[Export[StringJoin["nucleusoutlinenew_",ToString[n],".tif"],outlinenucleus[[n]]],{n,1,Length[outlinenucleus]}]

Export["allfocaladhesionsfilter.png",#,"png"]&/@removebackground7;
Export["allfocaladhesions.png",#,"png"]&/@imageadhesions7;

Actin:

mytableactin={componentsgreenarea,componentsgreenlongaxis,componentsgreenshortaxis,componentsgreenelongation,componentsgreenperimeter,componentsgreenangle2,Lengthcell}//Transpose;
headers={"Cell area","Long axis","Short axis","Elongation","Perimeter","Orientation actin","Length Cell"};
dataactin=Prepend[mytableactin,headers];
Export["dataactinmultiple.xls",dataactin];

Nucleus:

mytablenucleus={componentsbluearea,componentsbluelongaxis,componentsblueshortaxis,componentsblueelongation,componentsblueperimeter,componentsblueangle2}//Transpose;
headersnucleus={"Nucleus area","Long axis","Short axis","Elongation","Perimeter","Orientation nucleus"};
datanucleus=Prepend[mytablenucleus,headersnucleus];
Export["datanucleusmultiple.xls",datanucleus];

Focal adhesions:

mytablefocal={Areafocalafter,longaxisfocal,shortaxisfocal,elongationfocal,Orientationfocal2}//Transpose;
headersfocal={"Focal area","Long axis","Short axis","Elongation","Orientation focal"};
datafocal=Prepend[mytablefocal,headersfocal];
Export["datafocalmultiple.xls",datafocal];

Single cell:

To analyze the focal adhesions of one single cell, you can select the cell of interest by tracing the cell with a red mask. Once you traced the cell of interest, push the buttons “croptotal”, “binfibronectincrop”, “cropfocal”, “cropactin”, 
“cropdapi”, “binbluecrop”, “quantifyfocalcrop”, “binactincrop” to select the cell. 
In imagenumber you can select the image of interest.

imagenumber=1;
actin=imagesactin[[imagenumber]];
nucleus=imagesnucleus[[imagenumber]];
focal=imagesfocal[[imagenumber]];
actincropcropsingle=actincrop[[imagenumber]];
nucleuscropsingle=nucleuscrop[[imagenumber]];
focalcropsingle=focalcrop[[imagenumber]];

exppic=ColorCombine[{focal,actin,nucleus}];
i=exppic;
k=focal;
l=actin;
m=nucleus;
n=nucleuscropsingle;
o=focalcropsingle;
p=actincropcropsingle;
Manipulate[parameterscrop=u;Row[{Show[i,Graphics[{Red,Opacity[0.6],Dynamic[Polygon[u]]},PlotRange->2,Background->White]],Panel[result]}],{{u,{{100,100}, {150,150},{250,250},{300,300},{350,350},{400,400},{450,450}}},Locator,LocatorAutoCreate->True},Button["Croptotal",result=crop[i,u]],Button["Cropfocal",cropfocalsingle=crop[k,u]],Button["Cropactin",cropactinsingle=crop[l,u]],Button["Cropdapi",cropdapisingle=crop[n,u]],Button["binbluecrop",cropbinbluesingle=crop[n,u]],Button["quantifyfocalcrop",cropquantifyfocalsingle=crop[o,u]],Button["binactincrop",cropbinactinsingle=crop[p,u]],Initialization:>(crop[i_,poly_]:=Module[{mask},mask=ColorNegate[Binarize[Rasterize[Graphics[Polygon[poly],PlotRangePadding->0,PlotRange->Transpose[{{0,0},ImageDimensions[i]}],ImageSize->ImageDimensions[i]]]]];
merge=ImageMultiply[i,mask]])]

crop1=parameterscrop[[1]]; 
crop2=parameterscrop[[2]];
crop3=parameterscrop[[3]];
crop4=parameterscrop[[4]];
crop5=parameterscrop[[5]];
crop6=parameterscrop[[6]];
poly=ColorNegate[Binarize[Rasterize[Graphics[Polygon[{crop1,crop2,crop3,crop4,crop5,crop6}],PlotRangePadding->0,PlotRange->Transpose[{{0,0},ImageDimensions[i]}],ImageSize->ImageDimensions[i]]]]];

croptotal=result;
cropbinactinsingle=cropbinactinsingle;
cropbinbluesingle=cropbinbluesingle;
cropquantifyfocalsingle=cropquantifyfocalsingle;

Data analysis single cells:

Nucleus:

This part can be used to quantify the different properties from the nucleus of one single cells, such as the elongation, orientation, area, etc. To only select nuclei and not some small 
background dots, you can use the command markerblue. Just increase the number to not include small background dots.

selectimagenucleussingle=SelectComponents[cropbinbluesingle,"Area",#>500&];
disTbluesingle=ImageAdjust[DistanceTransform[selectimagenucleussingle]];
markerbluesingle=MaxDetect[disTbluesingle,0.3];
watershedComponentsbluesingle=WatershedComponents[ColorNegate[disTbluesingle],markerbluesingle]*ImageData[selectimagenucleussingle];
imagenucleussingle=Colorize[watershedComponentsbluesingle]
componentsbluesingle=ComponentMeasurements[{watershedComponentsbluesingle,disTbluesingle},{"Centroid","SemiAxes","Orientation","Max"}];
componentsbluecentroidsingle=ComponentMeasurements[watershedComponentsbluesingle,"Centroid"]/.Rule[a_,b_]->b;
componentsblueelongationsingle=Flatten[ComponentMeasurements[watershedComponentsbluesingle,"Elongation"]]/.Rule[a_,b_]->b;
componentsbluelongaxissingle=Flatten[ComponentMeasurements[watershedComponentsbluesingle,"Length"]]/.Rule[a_,b_]->b*factor;
componentsblueareasingle=Flatten[ComponentMeasurements[watershedComponentsbluesingle, "Area"]]/.Rule[a_,b_]->b*(factor^2);
Orientationblueanglesingle=(180/Pi)*Flatten[ComponentMeasurements[watershedComponentsbluesingle, "Orientation"]]/.Rule[a_,b_]->b;
Orientationblueangle2single=If[#<0,180-Abs[#],#]&/@Orientationblueanglesingle;
fitellipsenucleussingle=Show[selectimagenucleussingle,Graphics[{Red,componentsbluesingle[[All,2]]/.{{centroid_,semiAxes_,orientation_,maxR_}:>Rotate[Disk[centroid,{semiAxes[[1]],semiAxes[[2]]}],orientation,centroid]}}]]

Cells:

This part can be used to quantify the different properties from one single cell, such as the elongation, orientation, area, etc.

disTgreensingle=ImageAdjust[DistanceTransform[cropbinactinsingle]];
markergreensingle=MaxDetect[disTgreensingle,0.3];
watershedComponentsgreensingle=WatershedComponents[ColorNegate[disTgreensingle],markergreensingle]*ImageData[cropbinactinsingle];
imagesingle=Colorize[watershedComponentsgreensingle]
componentsgreensingle=ComponentMeasurements[{watershedComponentsgreensingle,disTgreensingle},{"Centroid","SemiAxes","Orientation","Max"}];
componentsgreenlongaxissingle=Flatten[ComponentMeasurements[{watershedComponentsgreensingle,disTgreensingle},{"Length"}]]/.Rule[a_,b_]->b*factor;
componentsgreenshortaxissingle=Flatten[ComponentMeasurements[{watershedComponentsgreensingle,disTgreensingle},{"Width"}]]/.Rule[a_,b_]->b*factor;
componentsgreenelongationsingle=Flatten[ComponentMeasurements[{watershedComponentsgreensingle,disTgreensingle},{"Elongation"}]]/.Rule[a_,b_]->b;
componentsgreenareasingle=Flatten[ComponentMeasurements[{watershedComponentsgreensingle,disTgreensingle},{"Area"}]]/.Rule[a_,b_]->b*(factor^2);
componentsgreenperimetersingle=Flatten[ComponentMeasurements[{watershedComponentsgreensingle,disTgreensingle},{"PolygonalLength"}]]/.Rule[a_,b_]->b*factor;
orientationgreenanglesingle=(180/Pi)*Flatten[ComponentMeasurements[watershedComponentsgreensingle, "Orientation"]]/.Rule[a_,b_]->b;
Orientationgreenangle2single=If[#<0,180-Abs[#],#]&/@orientationgreenanglesingle;
Lengthcellsingle=Flatten[ComponentMeasurements[watershedComponentsgreensingle,"CaliperLength"]]/.Rule[a_,b_]->b*factor
fitellipseactinsingle=Show[cropbinactinsingle,Graphics[{Red,componentsgreensingle[[All,2]]/.{{centroid_,semiAxes_,orientation_,maxR_}:>Rotate[Disk[centroid,{semiAxes[[1]],semiAxes[[2]]}],orientation,centroid]}}]]

Focal adhesions:

This part is used to quantify the different properties from the focal adhesions of one single cell of interest, such as the elongation, orientation, area, etc. FAs smaller than 0.1 um^2 (size can be adjusted in sizefocal) are excluded to 
ensure that background noise is eliminated from the analysis.

sizefocal=0.1;
selectfocalareanewsingle=SelectComponents[cropquantifyfocalsingle, "Area",sizefocal/(factor^2)<#&];
shortaxisfocalsingle=Flatten[ComponentMeasurements[selectfocalareanewsingle,"Width"]]/.Rule[a_,b_]->b*factor;
longaxisfocalsingle=Flatten[ComponentMeasurements[selectfocalareanewsingle,"Length"]]/.Rule[a_,b_]->b*factor;
centroidfocalsingle=Flatten[ComponentMeasurements[selectfocalareanewsingle,"Centroid"]]/.Rule[a_,b_]->b;
elongationfocalsingle=Flatten[ComponentMeasurements[selectfocalareanewsingle,"Elongation"]]/.Rule[a_,b_]->b;
lengthfocalsingle=Flatten[ComponentMeasurements[selectfocalareanewsingle,"CaliperLength"]]/.Rule[a_,b_]->b*factor;
perimeterfocalsingle=Flatten[ComponentMeasurements[selectfocalareanewsingle,"PolygonalLength"]]/.Rule[a_,b_]->b*factor;
areafocalsingle=Flatten[ComponentMeasurements[selectfocalareanewsingle, "Area"]]/.Rule[a_,b_]->b*(factor^2);
Orientationfocalsingle=(180/Pi)*Flatten[ComponentMeasurements[selectfocalareanewsingle, "Orientation"]]/.Rule[a_,b_]->b;
Orientationfocal2single=If[#<0,180-Abs[#],#]&/@Orientationfocalsingle;
spatialdistributionfocalsingle=Outer[EuclideanDistance,componentsbluecentroidsingle,centroidfocalsingle,1]*factor//Flatten;
fitellipsefocalsingle=ComponentMeasurements[selectfocalareanewsingle,{"Centroid","SemiAxes","Orientation","Max"}];
Show[selectfocalareanewsingle,Graphics[{Red,fitellipsefocalsingle[[All,2]]/.{{centroid_,semiAxes_,orientation_,maxR_}:>Rotate[Disk[centroid,{semiAxes[[1]],semiAxes[[2]]}],orientation,centroid]}}]]

Export:

This part can be used to export the images of the single cells, nuclei and focal adhesions.
The extracted data from these cells, nuclei and focal adhesions are exported to an excel file.

SetDirectory[dir];
Export["allfocaladhesionsfilter.png",#,"png"]&/@removebackground7;
Export["allfocaladhesions.png",#,"png"]&/@imageadhesions7;
Export["singleactin.png",cropbinactinsingle,"png"];
Export["singlenucleus.png",cropbinbluesingle,"png"];
Export["singlefocaladhesions.png",selectfocalareanewsingle,"png"];

Single cells:

actinarea=PadRight[Flatten[componentsgreenareasingle],Length[Orientationfocal2single]];
actinelongation=PadRight[Flatten[componentsgreenelongationsingle],Length[Orientationfocal2single]];
actinelongaxis=PadRight[Flatten[componentsgreenlongaxissingle],Length[Orientationfocal2single]];
actinorientation=PadRight[Flatten[Orientationgreenangle2single],Length[Orientationfocal2single]];

nucleusarea=PadRight[Flatten[componentsblueareasingle],Length[Orientationfocal2single]];
nucleuselongation=PadRight[Flatten[componentsblueelongationsingle],Length[Orientationfocal2single]];
nucleuslongaxis=PadRight[Flatten[componentsbluelongaxissingle],Length[Orientationfocal2single]];
nucleusorientation=PadRight[Flatten[Orientationblueangle2single],Length[Orientationfocal2single]];

mytablesinglecells={actinarea,actinelongation,actinelongaxis,actinorientation,nucleusarea,nucleuselongation,nucleuslongaxis,nucleusorientation,shortaxisfocalsingle,longaxisfocalsingle,elongationfocalsingle,lengthfocalsingle,areafocalsingle,Orientationfocal2single,spatialdistributionfocalsingle}//Transpose;
headerssinglecells={"Area cell","Elongation cell","Long axis cell","Orientation cell","Area nucleus","Elongation nucleus","Long axis nucleus","Orientation nucleus","Short axis focal","Long axis focal","Elongation focal","Length focal","Area focal", "Orientation focal","Distance focal"};
datasinglecells=Prepend[mytablesinglecells,headerssinglecells];
Export["datasinglecells.xls",datasinglecells,"XLS"];