Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MSD Track Processor
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bioimage Analysis
MSD Track Processor
Compare revisions
10c3044a482d1ec0509010c709bb2b910a820ec3 to be26cac7fe2f6ffcaf44c055058703e7bc1b7f2b
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
bia/msd-track-processor
Select target project
No results found
be26cac7fe2f6ffcaf44c055058703e7bc1b7f2b
Select Git revision
Branches
icy-3.0.0
master
Tags
v1.1.4
v2.0.0-a.1
Swap
Target
bia/msd-track-processor
Select target project
bia/msd-track-processor
1 result
10c3044a482d1ec0509010c709bb2b910a820ec3
Select Git revision
Branches
icy-3.0.0
master
Tags
v1.1.4
v2.0.0-a.1
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Fixed MSD computation for partially clipped / enabled tracks
· b5370f77
Stéphane DALLONGEVILLE
authored
2 years ago
b5370f77
updated version
· be26cac7
Stéphane DALLONGEVILLE
authored
2 years ago
be26cac7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pom.xml
+1
-1
1 addition, 1 deletion
pom.xml
src/main/java/plugins/fab/trackmanager/processors/TrackProcessorMSD.java
+135
-82
135 additions, 82 deletions
...lugins/fab/trackmanager/processors/TrackProcessorMSD.java
with
136 additions
and
83 deletions
pom.xml
View file @
be26cac7
...
...
@@ -13,7 +13,7 @@
<!-- Project Information -->
<artifactId>
msd-track-processor
</artifactId>
<version>
1.1.
2
</version>
<version>
1.1.
3
</version>
<packaging>
jar
</packaging>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/plugins/fab/trackmanager/processors/TrackProcessorMSD.java
View file @
be26cac7
...
...
@@ -105,14 +105,19 @@ public class TrackProcessorMSD extends PluginTrackManagerProcessor implements Ac
{
XYSeries
series
=
new
XYSeries
(
"Track "
+
trackPool
.
getTrackIndex
(
ts
));
if
(
ts
.
isAllDetectionEnabled
())
// Better to allow partially clipped tracks otherwise we cannot get MSD for them (Stephane)
// TODO: check that it doesn't bring any regression
// if (ts.isAllDetectionEnabled())
{
double
[]
msd
=
scaledMeanSquaredDisplacement
(
seq
,
ts
);
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++)
series
.
add
(
i
*
tScale
,
msd
[
i
]);
if
(
msd
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++)
series
.
add
(
i
*
tScale
,
msd
[
i
]);
xyDataset
.
addSeries
(
series
);
xyDataset
.
addSeries
(
series
);
}
}
}
}
...
...
@@ -122,14 +127,19 @@ public class TrackProcessorMSD extends PluginTrackManagerProcessor implements Ac
{
XYSeries
series
=
new
XYSeries
(
"Track "
+
trackPool
.
getTrackIndex
(
ts
));
if
(
ts
.
isAllDetectionEnabled
())
// Better to allow partially clipped tracks otherwise we cannot get MSD for them (Stephane)
// TODO: check that it doesn't bring any regression
// if (ts.isAllDetectionEnabled())
{
double
[]
msd
=
scaledMeanSquaredDisplacement
(
null
,
ts
);
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++)
series
.
add
(
i
,
msd
[
i
]);
if
(
msd
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++)
series
.
add
(
i
,
msd
[
i
]);
xyDataset
.
addSeries
(
series
);
xyDataset
.
addSeries
(
series
);
}
}
}
}
...
...
@@ -203,9 +213,11 @@ public class TrackProcessorMSD extends PluginTrackManagerProcessor implements Ac
outputName
=
trackPool
.
getDisplaySequence
().
getFilename
();
outputName
+=
".msd.xls"
;
}
else
outputName
=
SaveDialog
.
chooseFileForResult
(
"XLS MSD export"
,
"tracks-msd"
,
".xls"
);
else
outputName
=
SaveDialog
.
chooseFileForResult
(
"XLS MSD export"
,
"tracks-msd"
,
".xls"
);
if
(
StringUtil
.
isEmpty
(
outputName
))
return
;
if
(
StringUtil
.
isEmpty
(
outputName
))
return
;
try
{
...
...
@@ -229,25 +241,31 @@ public class TrackProcessorMSD extends PluginTrackManagerProcessor implements Ac
int
row
=
0
;
for
(
TrackSegment
ts
:
trackPool
.
getTrackSegmentList
())
{
if
(
ts
.
isAllDetectionEnabled
())
// Better to allow partially clipped tracks otherwise we cannot get MSD for them (Stephane)
// TODO: check that it doesn't bring any regression
// if (ts.isAllDetectionEnabled())
{
System
.
out
.
println
(
"track "
+
cnt
);
if
(
page
!=
null
)
XLSUtil
.
setCellString
(
page
,
0
,
row
,
"track "
+
cnt
);
double
[]
msd
=
scaledMeanSquaredDisplacement
(
seq
,
ts
);
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++)
if
(
msd
.
length
>
0
)
{
System
.
out
.
println
((
i
*
tScale
)
+
"\t"
+
msd
[
i
]);
// System.out.println(i + "\t" + msd[i]);
System
.
out
.
println
(
"track "
+
cnt
);
if
(
page
!=
null
)
XLSUtil
.
setCellNumber
(
page
,
i
+
1
,
row
,
msd
[
i
]);
}
XLSUtil
.
setCellString
(
page
,
0
,
row
,
"track "
+
cnt
);
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++)
{
System
.
out
.
println
((
i
*
tScale
)
+
"\t"
+
msd
[
i
]);
// System.out.println(i + "\t" + msd[i]);
if
(
page
!=
null
)
XLSUtil
.
setCellNumber
(
page
,
i
+
1
,
row
,
msd
[
i
]);
}
cnt
++;
row
++;
cnt
++;
row
++;
}
}
}
}
...
...
@@ -258,26 +276,30 @@ public class TrackProcessorMSD extends PluginTrackManagerProcessor implements Ac
for
(
TrackSegment
ts
:
trackPool
.
getTrackSegmentList
())
{
if
(
ts
.
isAllDetectionEnabled
())
// Better to allow partially clipped tracks otherwise we cannot get MSD for them (Stephane)
// TODO: check that it doesn't bring any regression
// if (ts.isAllDetectionEnabled())
{
System
.
out
.
println
(
"track "
+
cnt
);
if
(
page
!=
null
)
XLSUtil
.
setCellString
(
page
,
0
,
row
,
"track "
+
cnt
);
double
[]
msd
=
scaledMeanSquaredDisplacement
(
null
,
ts
);
// double[] msd = meanSquaredDisplacement(ts);
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++
)
if
(
msd
.
length
>
0
)
{
System
.
out
.
println
(
i
+
"\t"
+
msd
[
i
]
);
System
.
out
.
println
(
"track "
+
cnt
);
if
(
page
!=
null
)
XLSUtil
.
setCellNumber
(
page
,
i
+
1
,
row
,
msd
[
i
]);
}
XLSUtil
.
setCellString
(
page
,
0
,
row
,
"track "
+
cnt
);
for
(
int
i
=
0
;
i
<
msd
.
length
;
i
++)
{
System
.
out
.
println
(
i
+
"\t"
+
msd
[
i
]);
cnt
++;
row
++;
if
(
page
!=
null
)
XLSUtil
.
setCellNumber
(
page
,
i
+
1
,
row
,
msd
[
i
]);
}
cnt
++;
row
++;
}
}
}
}
...
...
@@ -320,65 +342,96 @@ public class TrackProcessorMSD extends PluginTrackManagerProcessor implements Ac
sz
=
1
d
;
}
int
nMSD
=
ts
.
getDetectionList
().
size
();
// double[] dt_n = new double[nMSD];
double
[]
msd
=
new
double
[
nMSD
];
final
int
numDetection
=
ts
.
getDetectionList
().
size
();
int
firstEnabledDetectionIndex
=
-
1
;
int
numEnabledDetection
=
0
;
int
lastFirstEnabledDetectionIndex
=
-
1
;
int
lastNumEnabledDetection
=
0
;
for
(
int
t
=
1
;
t
<
nMSD
;
t
++)
// Find partially enabled/clipped tracks otherwise we cannot get MSD for them (Stephane)
// TODO: check that it doesn't bring any regression
for
(
int
i
=
0
;
i
<
numDetection
;
i
++)
{
msd
[
t
]
=
0
d
;
for
(
int
j
=
1
;
j
<=
t
;
j
++)
msd
[
t
]
+=
scaledSquaredDistance
(
ts
.
getDetectionAt
(
0
),
ts
.
getDetectionAt
(
j
),
sx
,
sy
,
sz
);
msd
[
t
]
/=
t
;
}
// for (int dt = 1; dt < nMSD; dt++)
// {
// for (int j = 0; (j + dt) < nMSD; j += dt)
// {
// msd[dt] += scaledSquaredDistance(ts.getDetectionAt(j), ts.getDetectionAt(j + dt), sx, sy, sz);
// dt_n[dt]++;
// }
// }
//
// for (int dt = 1; dt < nMSD; dt++)
// msd[dt] = (dt_n[dt] != 0) ? msd[dt] / dt_n[dt] : 0;
final
Detection
d
=
ts
.
getDetectionAt
(
i
);
return
msd
;
}
// mean squared displacement
private
double
[]
meanSquaredDisplacement
(
TrackSegment
ts
)
{
int
nMSD
=
ts
.
getDetectionList
().
size
();
if
(
d
.
isEnabled
())
{
// start of track
if
(
lastFirstEnabledDetectionIndex
==
-
1
)
{
lastFirstEnabledDetectionIndex
=
i
;
lastNumEnabledDetection
=
1
;
}
else
lastNumEnabledDetection
++;
}
else
{
// check if last track is the longest found
if
(
lastNumEnabledDetection
>
numEnabledDetection
)
{
numEnabledDetection
=
lastNumEnabledDetection
;
firstEnabledDetectionIndex
=
lastFirstEnabledDetectionIndex
;
}
double
[]
dt_n
=
new
double
[
nMSD
];
double
[][]
msd
=
new
double
[
nMSD
][
2
];
// reset track
lastFirstEnabledDetectionIndex
=
-
1
;
lastNumEnabledDetection
=
0
;
}
}
for
(
int
dt
=
1
;
dt
<
nMSD
;
dt
++)
// check if last track is the longest found
if
(
lastNumEnabledDetection
>
numEnabledDetection
)
{
msd
[
dt
][
0
]
=
dt
*
1
;
for
(
int
j
=
0
;
j
+
dt
<
ts
.
getDetectionList
().
size
();
j
+=
dt
)
{
msd
[
dt
][
1
]
+=
squaredDistance
(
ts
.
getDetectionAt
(
j
),
ts
.
getDetectionAt
(
j
+
dt
));
dt_n
[
dt
]++;
}
numEnabledDetection
=
lastNumEnabledDetection
;
firstEnabledDetectionIndex
=
lastFirstEnabledDetectionIndex
;
}
for
(
int
dt
=
1
;
dt
<
nMSD
;
dt
++)
msd
[
dt
][
1
]
=
(
dt_n
[
dt
]
!=
0
)
?
msd
[
dt
][
1
]
/
dt_n
[
dt
]
:
0
;
double
[]
msd
=
new
double
[
numEnabledDetection
];
double
[]
resultmsd
=
new
double
[
nMSD
];
resultmsd
[
0
]
=
0
;
for
(
int
dt
=
1
;
dt
<
nMSD
;
dt
++)
resultmsd
[
dt
]
=
msd
[
dt
][
1
];
for
(
int
t
=
1
;
t
<
numEnabledDetection
;
t
++)
{
msd
[
t
]
=
0
d
;
for
(
int
j
=
1
;
j
<=
t
;
j
++)
msd
[
t
]
+=
scaledSquaredDistance
(
ts
.
getDetectionAt
(
firstEnabledDetectionIndex
),
ts
.
getDetectionAt
(
firstEnabledDetectionIndex
+
j
),
sx
,
sy
,
sz
);
return
resultmsd
;
msd
[
t
]
/=
t
;
}
return
msd
;
}
// mean squared displacement
// private double[] meanSquaredDisplacement(TrackSegment ts)
// {
// int nMSD = ts.getDetectionList().size();
//
// double[] dt_n = new double[nMSD];
// double[][] msd = new double[nMSD][2];
//
// for (int dt = 1; dt < nMSD; dt++)
// {
// msd[dt][0] = dt * 1;
//
// for (int j = 0; j + dt < ts.getDetectionList().size(); j += dt)
// {
// msd[dt][1] += squaredDistance(ts.getDetectionAt(j), ts.getDetectionAt(j + dt));
// dt_n[dt]++;
// }
// }
//
// for (int dt = 1; dt < nMSD; dt++)
// msd[dt][1] = (dt_n[dt] != 0) ? msd[dt][1] / dt_n[dt] : 0;
//
// double[] resultmsd = new double[nMSD];
// resultmsd[0] = 0;
// for (int dt = 1; dt < nMSD; dt++)
// resultmsd[dt] = msd[dt][1];
//
// return resultmsd;
//
// }
private
static
double
squaredDistance
(
Detection
d1
,
Detection
d2
)
{
return
scaledSquaredDistance
(
d1
,
d2
,
1
d
,
1
d
,
1
d
);
...
...
This diff is collapsed.
Click to expand it.