diff --git a/deploy.m b/deploy.m index 060237e..86ed1a9 100644 --- a/deploy.m +++ b/deploy.m @@ -5,4 +5,17 @@ % Ensure all folders are on the path addpath(genpath(path)); -mcc -v -m SpectralAnalysis.m -a lib/ -a src/ -a *.m \ No newline at end of file +% Compile preprocessing methods +cd 'src/processing/preprocessing/' + +mex -largeArrayDims rebin.c +mex -largeArrayDims synaptReplaceZeros.c + +cd '../../../' + +% Compile MEPCA methods +cd 'src/processing/postprocessing/mepca' +compileMEPCA +cd '../../../../' + +mcc -v -m SpectralAnalysis.m -a lib/ -a src/ -a *.m -a *.mex* \ No newline at end of file diff --git a/lib/JSpectralAnalysis/JSpectralAnalysis.jar b/lib/JSpectralAnalysis/JSpectralAnalysis.jar index fcd5583..2bd09a7 100644 Binary files a/lib/JSpectralAnalysis/JSpectralAnalysis.jar and b/lib/JSpectralAnalysis/JSpectralAnalysis.jar differ diff --git a/src/gui/DataViewer.m b/src/gui/DataViewer.m index 98c9c33..9abfb14 100644 --- a/src/gui/DataViewer.m +++ b/src/gui/DataViewer.m @@ -85,6 +85,7 @@ % Buttons for interacting with the spectrum list addSpectrumButton; overlaySpectrumButton; + subtractSpectrumButton; removeSpectrumButton; switchSpectrumViewButton; @@ -788,18 +789,59 @@ function overlaySpectrumCallback(obj) % axisHandle = axes; multiSpectrumPanel = MultiSpectrumPanel(figure, obj.spectrumList.get(spectraToOverlay(1))); - warning('No preprocessing applied...'); + spectraToOverlayList = []; + for i = 1:length(spectraToOverlay) + if(i == 1) + spectraToOverlayList = obj.spectrumList.get(spectraToOverlay(i)); + else + spectraToOverlayList(i) = obj.spectrumList.get(spectraToOverlay(i)); + end + + if(~isempty(obj.preprocessingWorkflow)) + spectraToOverlayList(i) = obj.preprocessingWorkflow.performWorkflow(spectraToOverlayList(i)); + end + end + multiSpectrumDisplay = multiSpectrumPanel.spectrumDisplay; for i = 2:length(spectraToOverlay) - multiSpectrumDisplay.setSpectrum(i, obj.spectrumList.get(spectraToOverlay(i))); + multiSpectrumDisplay.setSpectrum(i, spectraToOverlayList(i)); end multiSpectrumDisplay.updateDisplay(); end end + function subtractSpectrumCallback(this) + spectraToSubstract = this.spectrumListTableLastSelected(:, 1); + + if(~isempty(spectraToSubstract) && length(spectraToSubstract) == 2) + + spectrum1 = this.spectrumList.get(spectraToSubstract(1)); + spectrum2 = this.spectrumList.get(spectraToSubstract(2)); + + if(~isempty(this.preprocessingWorkflow)) + spectrum1 = this.preprocessingWorkflow.performWorkflow(spectrum1); + spectrum2 = this.preprocessingWorkflow.performWorkflow(spectrum2); + end + + try + differenceSpectrum = SpectralData(spectrum1.spectralChannels, spectrum1.intensities - spectrum2.intensities); + + figure = Figure(); + figure.showStandardFigure(); + spectrumPanel = SpectrumPanel(figure, differenceSpectrum); + + figure.setTitle(['Difference between ' spectrum1.getDescription() ' and ' spectrum2.getDescription()]); + catch err + errordlg(err.message); + end + else + errordlg('Please select 2 spectra to subtract', 'DataViewer:NoSpectraSelected'); + end + end + %% editPreprocessingWorkflow() function editPreprocessingWorkflow(obj) assignin('base', 'dataViewer', obj); @@ -1101,6 +1143,9 @@ function createFigure(obj) obj.overlaySpectrumButton = uicontrol('Parent', obj.spectrumListPanel, 'String', 'O', ... 'Callback', @(src, evnt) obj.overlaySpectrumCallback(), ... 'TooltipString', 'Overlay selected spectra'); + obj.subtractSpectrumButton = uicontrol('Parent', obj.spectrumListPanel, 'String', 'S', ... + 'Callback', @(src, evnt) obj.subtractSpectrumCallback(), ... + 'TooltipString', 'Subtract selected spectra'); obj.removeSpectrumButton = uicontrol('Parent', obj.spectrumListPanel, 'String', '-', ... 'Callback', @(src, evnt) obj.removeSpectraFromListCallback(), ... 'TooltipString', 'Remove selected spectra from the list'); @@ -1291,7 +1336,8 @@ function sizeChanged(obj) Figure.setObjectPositionInPixels(obj.addSpectrumButton, [margin, margin, panelPosition(3)/5 - margin*2, buttonHeight]); Figure.setObjectPositionInPixels(obj.overlaySpectrumButton, [margin+panelPosition(3)/5, margin, panelPosition(3)/5 - margin*2, buttonHeight]); - Figure.setObjectPositionInPixels(obj.removeSpectrumButton, [margin+panelPosition(3)*2/5, margin, panelPosition(3)/5 - margin*2, buttonHeight]); + Figure.setObjectPositionInPixels(obj.subtractSpectrumButton, [margin+panelPosition(3)*2/5, margin, panelPosition(3)/5 - margin*2, buttonHeight]); + Figure.setObjectPositionInPixels(obj.removeSpectrumButton, [margin+panelPosition(3)*3/5, margin, panelPosition(3)/5 - margin*2, buttonHeight]); end widthForSpectrum = widthForSpectrum - widthOfSpectrumList - margin; diff --git a/src/gui/RegionOfInterestListEditor.m b/src/gui/RegionOfInterestListEditor.m index 0f6a8c5..741b56c 100644 --- a/src/gui/RegionOfInterestListEditor.m +++ b/src/gui/RegionOfInterestListEditor.m @@ -12,6 +12,8 @@ editROIButton; removeROIButton; + autoROIButton; + regionOfInterestEditor = 0; roiFinishedEditingListener = 0; @@ -70,6 +72,22 @@ function addRegionOfInterestCallback(this) 'FinishedEditing', @(src, evnt)this.finishedEditingRegionOfInterest(src.getRegionOfInterest())); end + function autoRegionOfInterestCallback(this) + for i = 1:this.image.getHeight() + newROI = RegionOfInterest(this.image.getWidth(), this.image.getHeight()); + newROI.setName(['Line ' num2str(i)]); + + roi = zeros(this.image.getHeight(), this.image.getWidth()); + roi(i, :) = 1; + + newROI.addPixels(roi); + + this.regionOfInterestList.add(newROI); + + this.updateRegionOfInterestList(); + end + end + function finishedEditingRegionOfInterest(this, regionOfInterest) if(~isa(regionOfInterest, 'RegionOfInterest')) exception = MException('RegionOfInterestListEditor:InvalidArgument', 'addRegionOfInterest: Must suply a RegionOfInterest.'); @@ -197,6 +215,9 @@ function createFigure(this) 'Units', 'normalized', 'Position', [0.6 0.125 0.1 0.05], 'Callback', @(src, evnt) this.editRegionOfInterest()); this.removeROIButton = uicontrol(this.handle, 'String', '-', ... 'Units', 'normalized', 'Position', [0.6 0.05 0.1 0.05], 'Callback', @(src, evnt) this.removeRegionOfInterestCallback()); + + this.autoROIButton = uicontrol(this.handle, 'String', 'Auto Line', ... + 'Units', 'normalized', 'Position', [0.8 0.2 0.1 0.05], 'Callback', @(src, evnt) this.autoRegionOfInterestCallback()); end end end \ No newline at end of file diff --git a/src/processing/postprocessing/mepca/compile.m b/src/processing/postprocessing/mepca/compileMEPCA.m similarity index 93% rename from src/processing/postprocessing/mepca/compile.m rename to src/processing/postprocessing/mepca/compileMEPCA.m index a9181b0..27b168a 100644 --- a/src/processing/postprocessing/mepca/compile.m +++ b/src/processing/postprocessing/mepca/compileMEPCA.m @@ -1,4 +1,3 @@ -mex -largeArrayDims rebin.c mex -largeArrayDims calculateE.c mex -largeArrayDims updateQ.c diff --git a/src/processing/preprocessing/InterpolationRebinZeroFilling.m b/src/processing/preprocessing/InterpolationRebinZeroFilling.m index 7664fb5..0b2e01b 100644 --- a/src/processing/preprocessing/InterpolationRebinZeroFilling.m +++ b/src/processing/preprocessing/InterpolationRebinZeroFilling.m @@ -19,6 +19,7 @@ sChannels = obj.Parameters(1).value:obj.Parameters(3).value:obj.Parameters(2).value; intensities = interp1(spectralChannels, intensities, sChannels); + intensities(isnan(intensities)) = 0; spectralChannels = sChannels; end end