Finding local minima and maxima of DSC curves using islocalmin and islocalmax

20 views (last 30 days)
DSC (Differential Scanning Calorimetry) is a thermal analysis method used in material science and chemistry to understand the thermal behavior of polymers or other organic/inorganic materials. The test is usually performed by a first heating cycle (to melt all the microcrystalline regions), followed by a cooling phase and a second heating. It is during the cooling and second heating that the crystallization and melting temperatures of a material are measured in the form of the temperature at which the heating has a local minimum or maximum.
The issue here: it is highly desirable to have a process for finding the crystallization and melting temperatures automatically, and I tried to use the islocalmin and islocalmax functions of matlab to find these values. As can be seen, multiple local minima and maxima are detected (symbols: red for minima and blue for maxima) but a lot of junk is also detected. In addition, there is an overlap in the minima and maxima, which means that, for some reason that I cannot understand, the program considers these both as minima and maxima. This is especially problematic in the section where a large naumber of points are detected nect to each other.
What I am interested in is only the local mainima/maxima pointed to by arrows. Is there a way to make the detection more specific to avoid the multiplicity seen here and reliably detect the most crucial points?
  7 Comments
Saeid
Saeid on 13 Dec 2021
Hi Matthieu,
I am not sure if I understand correctly that you have now changed my code to get rid of the multiple minima/maxima or if this is just a question? If that's a question, then the answer is that you can of course only load one file or mutliple files. But if the attached code is supposed to be changed, I ran it, and it seems to give the same results.
Mathieu NOE
Mathieu NOE on 13 Dec 2021
hello
suggestion for today - late evening
clc; clear all; format long g; close all
% [FileName,FilePath,~] = uigetfile({'*.txt*'},'MultiSelect','On');
OutFile='AllOutput.xlsx';
% IF=length(FileName);
FilePath = pwd;
FileName = {'TestForMatlab_1.txt'};
IF=length(FileName);
for ii=1:IF
InFile=char(FileName(ii));
InFilePath=fullfile(FilePath,char(FileName(ii)));
RAWW=readtable(InFilePath,'Delimiter','tab');
RAWW=table2array(RAWW); RAWW=replace(RAWW,',','.');
Data=str2double(RAWW);
InDat=fileread(InFilePath);
ISize=strfind(InDat,'Size');
Img=strfind(InDat,'mg');
SampleWeight=InDat(ISize(1)+4:Img(1)-1);
mSample(ii)=str2double(replace(SampleWeight,',','.'));
TT=Data(:,2);WW=Data(:,3)/mSample(ii); tt=Data(:,1);
% keep only positive slope (of TT) data
ind= find(diff(TT)>100/1e4);
TT=TT(ind);WW=WW(ind); tt=tt(ind);
TW=[TT WW];
% add some smoothing to avoid "multi hits" of islocalmin
WW = smoothdata(WW,'gaussian',20);
IsMinW=islocalmin((WW),'FlatSelection', 'center');
IsMaxW=islocalmax((WW),'FlatSelection', 'center');
IsMinW = find(IsMinW);
IsMinW = [IsMinW(1) IsMinW(end)]; % forget the intermediate points , keep only first and last one
IsMaxW = find(IsMaxW);
IsMaxW = [IsMaxW(1) IsMaxW(end)]; % forget the intermediate points , keep only first and last one
T_WMin=TT(IsMinW); WMin=WW(IsMinW);
T_WMax=TT(IsMaxW); WMax=WW(IsMaxW);
TabName=['43281_' num2str(ii)];
HeatingRate=gradient(TT)./gradient(tt);
%xlswrite(OutFile,TW,TabName);
subplot(2,2,[1 3])
plot(TT,WW,'k-',T_WMin,WMin,'rd',T_WMax,WMax,'bd','LineWidth',1.5,'Markersize',15)
hold on;
%zz=findchangepts(WW)
subplot(2,2,2)
%plot(tt,TT,'LineWidth',1.5)
plot(linspace(1,length(TT),length(TT)),WW,'LineWidth',1.5)
%
%plot(tt,gradient(TT),'LineWidth',1.5)
subplot(2,2,4)
plot(linspace(1,length(TT),length(TT)),HeatingRate,'LineWidth',1.5)
%plot(tt,gradient(TT))
%plot(tt,TT,'LineWidth',1.5)
hold on
TMax=max(unique(floor(TT(islocalmax(TT)))))'
TMin=min(unique(floor(TT(islocalmin(TT)))))'
%size(abs(TT-TMin)>1)
end

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!