Skip to content

Commit 60a3713

Browse files
committed
Filter out complex SEs if generated.
1 parent 4b99a84 commit 60a3713

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

MATLAB/+smi/@SMLM/SMLM.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ function analyzeAll(obj, DatasetList)
297297
end
298298
[SMD] = LD.genLocalizations();
299299

300+
% Filter out any localizations with nonzero imaginary standard errors.
301+
SMD = smi_helpers.Filters.filterImag(SMD, obj.Verbose);
302+
300303
% Keep track of why localizations were filtered out.
301304
obj.SMDPreThresh = smi_core.SingleMoleculeData.catSMD( ...
302305
obj.SMDPreThresh, LD.SMDPreThresh, false);

MATLAB/+smi_helpers/@Filters/Filters.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
SMD = filterFC(SMD, Verbose, nFC)
1919
SMD = filterNN(SMD, Verbose, n_NN, MedianMultiplier)
2020

21+
SMD = filterImag(SMD, Verbose)
22+
2123
end % methods(Static)
2224

2325
end % classdef Filters

MATLAB/+smi_helpers/@Filters/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ static methods:
2525
filter out localizations representing fewer than nFC frame connections
2626
- **[filterNN](filterNN.m)**:
2727
localizations are filtered based on the nearest neighbor distance
28+
- **[filterImag](filterImag.m)**:
29+
filter out _SE SMD fields with non-zero imaginary components
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
function SMD = filterImag(SMD, Verbose)
2+
%filterImag: Filter out _SE SMD fields with non-zero imaginary components.
3+
%
4+
% INPUT:
5+
% SMD Single Molecule Data structure
6+
% Verbose verbosity flag [DEFAULT = false]
7+
%
8+
% OUTPUT:
9+
% SMD modified Single Molecule Data structure
10+
11+
% Created by
12+
% Michael J. Wester (5/23/2025)
13+
14+
if ~exist('Verbose', 'var')
15+
Verbose = false;
16+
end
17+
18+
n_prefilter = numel(SMD.X);
19+
20+
% Find SMD fields that contain an SE in their name.
21+
f = fields(SMD);
22+
SE = f(contains(f, '_SE'));
23+
% Eliminate fields that do not contain n_prefilter elements.
24+
inuse = arrayfun(@(i) numel(SMD.(SE{i})) == n_prefilter, 1:numel(SE));
25+
SEinuse = SE(inuse);
26+
27+
% Check the fields for nonzero imaginary values.
28+
complex = [];
29+
for i = 1 : numel(SEinuse)
30+
complex = union(complex, find(imag(SMD.(SE{i})) ~= 0));
31+
end
32+
33+
noncomplex = setdiff(1:n_prefilter, complex);
34+
SMD = smi_core.SingleMoleculeData.isolateSubSMD(SMD, noncomplex);
35+
36+
if Verbose >= 2 && numel(SMD.X) ~= n_prefilter
37+
fprintf(' Complex standard errors removed = %d out of %d\n', ...
38+
n_prefilter - numel(SMD.X), n_prefilter);
39+
end
40+
41+
end

0 commit comments

Comments
 (0)