# Size (and shape) matters – especially at the nanoscale (Part 2)

In the first part we used Fiji to measure the size and shape of our SmartFlare Nanoparticles. After having done this with a couple of different TEM images we want to analyse these data and get some useful numbers and graphs.

#### A quick word on shape descriptors

The details of Fiji’s shape descriptors can be found here and are paraphrased below:

• Ellipse: Describes the Major and Minor axes of the best fitting ellipse.
• Circularity: 4π*area/perimeter^2. A value of 1.0 indicates a perfect circle. As the value approaches 0.0, it indicates an increasingly elongated shape.
• Aspect Ratio: major_axis/minor_axis
• Roundness: 4*area/(π*major_axis^2), or the inverse of the aspect ratio.
• Solidity: area/convex area.

Although we can analyse any of the descriptors, for the sake of brevity, we’ll stick to the Minor elliptical axis (which gives us a measure of particle diameter).

#### MATLAB enters the ring

Matlab is an incredibly powerful tool for data analysis in Research Science, although sometimes I feel that it scares people off, as it requires a degree of abstraction in the way you think about numbers (compared to Excel, for example where you can see all of the numbers in little grids).

#### Step 1: Import the data

Whether you copy / paste the data straight from Fiji’s results table or save the data as a spreadsheet, you need to get the numbers into MATLAB. My data are in a spreadsheet so I use the function xlsread to pull the numbers from Sheet 1:

`data=xlsread('2015-03-03_TEM_analysis.xlsx',1);`

#### Step 2: Basic analysis

I’m going to use the Minor Axis as an example (which is column 5 in the data array). The first thing we probably want, is to calculate the averages of the data, which is easily enough done with the following lines:

```mean(data(:,5))
median(data(:,5))
mode(data(:,5))
```

Which returns: 13.9060, 13.6580 and 13.7670 respectively. So far, so good (remember that we’re expecting ~13nm particles). Remember though that this is the minor axis which will always be less than (or for a circle, equal to) the major axis.

#### Step 3: Calculate the distributions

Single values are good but don’t tell us anything about the range or variance in the data. For that and a more visual approach, we use the hist function to calculate the distribution:

`[freq, num]=hist(data(:,5), round(sqrt(size(data,1))));`

Above we’re asking hist to take every row (:) of the 5th column from the array data and find the distribution broken down into 16 bins. The number of bins is an interesting and often argued choice. For ease, I’ve used the square root of the number of values (round is used to make sure that number is an integer as you can’t have 0.6 of a bin).

You can easily plot the resulting data as a histogram using:

`bar(num,freq);`

And after adding a little embellishment:

```xlabel('Minor Axis (nm)', 'fontsize', 12);
ylabel('Frequency', 'fontsize', 12);
title(['Distribution of Minor Axis' 10 'Mean = ' num2str(mean(data(:,5)),'%.3g') ' nm'], 'fontsize', 12);
```

You end up with something that looks like this: Nice!

#### Step 4: Model the distributions

For the ultimate boss-pleaser (although it’s mostly an aesthetic addition) you can always fit the distribution with a model. We would probably expect the distribution to be represented by a single-component gaussian distribution, therefore we use the fit function with the ‘gauss1’ model:

```fit1=fit(num',freq','gauss1');
```

Note that fit requires columnar data, so the single quote (‘) is used to transpose the data. If the existing figure is still open, we can plot the curve fit on top:

```hold on %-- don't replace the existing data
plot(fit1) %-- plot the curve data
```

Which will give you: Visually the fit doesn’t look great (the R2 value for the fit is 0.9358), although this is likely due to the small number of nanoparticles analysed (n=251).

#### Step 5: Rinse and repeat

Once you’ve done an analysis once in MATLAB, the beauty is the ability to re-run the same analysis on different datasets to give us loads of information about our nanoparticles. 