Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Track Analyzer
track-analyzer
Commits
fba7cfd7
Commit
fba7cfd7
authored
Jan 31, 2022
by
amichaut
Browse files
updated copyright + replaced verbosity by quiet flag
parent
7ca8f1ac
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
doc/source/_static/example/load_tracking.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
doc/source/developer_guide/index.rst
View file @
fba7cfd7
...
...
@@ -2,7 +2,7 @@
Authors: Arthur Michaut
Copyright 2016-2019 Harvard Medical School and Brigham and
Women's Hospital
Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738
Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738
See the COPYRIGHT file for details
This file is part of Track Analyzer package.
...
...
doc/source/user_guide/index.rst
View file @
fba7cfd7
...
...
@@ -2,7 +2,7 @@
Authors: Arthur Michaut
Copyright 2016-2019 Harvard Medical School and Brigham and
Women's Hospital
Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738
Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738
See the COPYRIGHT file for details
This file is part of Track Analyzer package.
...
...
doc/source/user_guide/installation.rst
View file @
fba7cfd7
...
...
@@ -2,7 +2,7 @@
Authors: Arthur Michaut
Copyright 2016-2019 Harvard Medical School and Brigham and
Women's Hospital
Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738
Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738
See the COPYRIGHT file for details
This file is part of Track Analyzer package.
...
...
doc/source/user_guide/quickstart.rst
View file @
fba7cfd7
...
...
@@ -2,7 +2,7 @@
Authors: Arthur Michaut
Copyright 2016-2019 Harvard Medical School and Brigham and
Women's Hospital
Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738
Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738
See the COPYRIGHT file for details
This file is part of Track Analyzer package.
...
...
run_TA.ipynb
View file @
fba7cfd7
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
setup.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
track_analyzer/__init__.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
track_analyzer/calculate.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
track_analyzer/deprecated.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
track_analyzer/plotting.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
é
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
@@ -110,15 +110,17 @@ def plot_cmap(plot_dir, label, cmap, vmin, vmax, plot_config=None, suffix=''):
def
plot_traj
(
df
,
frame
,
data_dir
,
groups
=
None
,
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
plot_dir
=
None
,
show_plot
=
False
,
dim
=
3
,
plot_config
=
None
,
traj_parameters
=
None
):
show_plot
=
False
,
dim
=
3
,
plot_config
=
None
,
traj_parameters
=
None
,
quiet
=
False
):
"""
Plot all trajectories of a given frame on an image if traj_parameters['no_bkg'] is False and an image is given.
Plots can be color coded z value, by groups, or with random colors (traj_parameters['color_code']='z' or 'group' or 'random' or 'none')
The trajectory path can be removed to keep only the dots if traj_parameters['traj'] is False.
It can be plotted in 3D with plot3D, elevation and angle set the 3D view
"""
sys
.
stdout
.
write
(
"
\033
[K"
)
# go back to previous line
print
(
'plotting frame {}'
.
format
(
int
(
frame
)),
flush
=
True
,
end
=
'
\r
'
)
if
not
quiet
:
sys
.
stdout
.
write
(
"
\033
[K"
)
# go back to previous line
print
(
'plotting frame {}'
.
format
(
int
(
frame
)),
flush
=
True
,
end
=
'
\r
'
)
# get config parameters
plot_config
=
make_plot_config
()
if
plot_config
is
None
else
plot_config
...
...
@@ -282,10 +284,10 @@ def plot_traj(df, frame, data_dir, groups=None, image={'image_fn': None, 't_dim'
def
plot_scalar_field
(
data_dir
,
df
,
data
,
field
,
frame
,
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
map_param
=
{
'no_bkg'
:
False
,
'vlim'
:
None
,
'show_axis'
:
False
,
'cmap'
:
'plasma'
},
plot_dir
=
None
,
plot_config
=
None
,
dont_print_coun
t
=
False
,
dont_save
=
False
):
plot_dir
=
None
,
plot_config
=
None
,
quie
t
=
False
,
dont_save
=
False
):
"""Plot scalar field as colormap. The data needs to be generated before. """
if
not
dont_print_coun
t
:
if
not
quie
t
:
sys
.
stdout
.
write
(
"
\033
[K"
)
# go back to previous line
print
(
'plotting {} {}'
.
format
(
field
,
int
(
frame
)),
flush
=
True
,
end
=
'
\r
'
)
...
...
@@ -362,10 +364,10 @@ def plot_vector_field(data_dir, df, data, field, frame, plot_on_field=None, dim=
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
map_param
=
{
'no_bkg'
:
False
,
'vlim'
:
None
,
'show_axis'
:
False
,
'cmap'
:
'plasma'
,
'size_factor'
:
1
},
plot_dir
=
None
,
plot_config
=
None
,
dont_print_coun
t
=
False
):
plot_dir
=
None
,
plot_config
=
None
,
quie
t
=
False
):
""" Plot vector field"""
if
not
dont_print_coun
t
:
if
not
quie
t
:
sys
.
stdout
.
write
(
"
\033
[K"
)
# go back to previous line
print
(
'plotting {} {}'
.
format
(
field
,
int
(
frame
)),
flush
=
True
,
end
=
'
\r
'
)
...
...
@@ -453,7 +455,7 @@ def plot_vector_field(data_dir, df, data, field, frame, plot_on_field=None, dim=
def
plot_Voronoi
(
data_dir
,
df
,
frame
,
data
,
show_local_area
=
True
,
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
map_param
=
{
'no_bkg'
:
False
,
'vlim'
:
None
,
'show_axis'
:
False
,
'cmap'
:
'plasma'
,
'size_factor'
:
1
,
'line_width'
:
1.
},
plot_dir
=
None
,
plot_config
=
None
,
dont_print_count
=
False
):
plot_dir
=
None
,
plot_config
=
None
,
dont_print_count
=
False
,
quiet
=
False
):
"""
Plot Voronoi tesselation and local area in 2D only.
:param data_dir:
...
...
@@ -469,7 +471,7 @@ def plot_Voronoi(data_dir, df, frame, data, show_local_area=True,
:return:
"""
if
not
dont_print_coun
t
:
if
not
quie
t
:
sys
.
stdout
.
write
(
"
\033
[K"
)
# go back to previous line
print
(
'plotting {} {}'
.
format
(
'voronoi'
,
int
(
frame
)),
flush
=
True
,
end
=
'
\r
'
)
...
...
@@ -694,6 +696,8 @@ def plot_param_vs_param(data_dir, x_param, y_param, df=None, hue=None, hue_order
if
plot_config
[
'despine'
]:
sns
.
despine
(
fig
)
ax
.
legend
(
frameon
=
False
)
filename
=
osp
.
join
(
plot_dir
,
prefix
+
'{}_vs_{}{}{}'
.
format
(
y_param
,
x_param
,
suffix
,
plot_config
[
'format'
]))
fig
.
savefig
(
filename
,
dpi
=
plot_config
[
'dpi'
],
bbox_inches
=
'tight'
)
plt
.
close
(
fig
)
...
...
@@ -737,16 +741,13 @@ def plot_param_hist(data_dir, param, df=None, hue=None, hue_order=None, hist=Tru
df
=
df
[
np
.
isfinite
(
df
[
param
])]
kind
=
"hist"
if
hist
else
"kde"
g
=
sns
.
displot
(
data
=
df
,
x
=
param
,
hue
=
hue
,
kind
=
kind
,
kde
=
kde
,
facet_kws
=
{
'legend_out'
:
False
})
sns
.
move_legend
(
g
,
"upper right"
,
frameon
=
False
)
g
=
sns
.
displot
(
data
=
df
,
x
=
param
,
hue
=
hue
,
kind
=
kind
,
kde
=
kde
,
facet_kws
=
{
'legend_out'
:
False
,
'despine'
:
plot_config
[
'despine'
]
})
sns
.
move_legend
(
g
,
"upper right"
,
frameon
=
False
,
bbox_to_anchor
=
[
0.95
,
0.95
],
title
=
None
)
fig
=
g
.
figure
ax
=
g
.
ax
fig
.
set_size_inches
(
figsize
[
0
],
figsize
[
1
])
ax
.
set_xlabel
(
param_label
)
if
plot_config
[
'despine'
]:
sns
.
despine
(
fig
)
filename
=
osp
.
join
(
plot_dir
,
prefix
+
'{}_hist{}{}'
.
format
(
param
,
suffix
,
plot_config
[
'format'
]))
fig
.
savefig
(
filename
,
dpi
=
plot_config
[
'dpi'
],
bbox_inches
=
'tight'
)
plt
.
close
(
fig
)
...
...
@@ -919,7 +920,7 @@ def view_traj(df, image=None, z_step=1):
def
plot_all_traj
(
data_dir
,
df
,
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
parallelize
=
False
,
dim
=
3
,
plot_dir
=
None
,
traj_parameters
=
None
,
plot_config
=
None
):
plot_dir
=
None
,
traj_parameters
=
None
,
plot_config
=
None
,
quiet
=
False
):
"""Plot traj for all frames"""
# plotting directory
...
...
@@ -1003,7 +1004,7 @@ def plot_all_traj(data_dir, df, image={'image_fn': None, 't_dim': None, 'z_dim':
frame
=
int
(
frame
)
fig
=
plot_traj
(
df
,
frame
,
data_dir
,
groups
=
groups
,
image
=
image
,
plot_dir
=
plot_dir
,
traj_parameters
=
traj_parameters
,
dim
=
dim
,
plot_config
=
plot_config
)
dim
=
dim
,
plot_config
=
plot_config
,
quiet
=
quiet
)
# append to stack
if
save_as_stack
:
...
...
@@ -1020,7 +1021,7 @@ def plot_all_traj(data_dir, df, image={'image_fn': None, 't_dim': None, 'z_dim':
def
plot_all_scalar_fields
(
data_dir
,
df
,
data
,
field
,
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
map_param
=
{
'no_bkg'
:
False
,
'vlim'
:
None
,
'show_axis'
:
False
,
'cmap'
:
'plasma'
},
plot_dir
=
None
,
plot_config
=
None
,
dont_print_coun
t
=
False
):
plot_dir
=
None
,
plot_config
=
None
,
quie
t
=
False
):
"""Plot scalar fields as colormap for all frames."""
# plotting directory
...
...
@@ -1051,7 +1052,8 @@ def plot_all_scalar_fields(data_dir, df, data, field, image={'image_fn': None, '
for
frame
in
np
.
sort
(
df
[
'frame'
].
unique
()):
frame
=
int
(
frame
)
fig
=
plot_scalar_field
(
data_dir
,
df
,
data
,
field
,
frame
,
image
=
image
,
map_param
=
map_param_
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
)
map_param
=
map_param_
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
quiet
=
quiet
)
# append to stack
if
save_as_stack
:
...
...
@@ -1071,7 +1073,7 @@ def plot_all_vector_fields(data_dir, df, data, field, plot_on_field=None, dim=3,
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
map_param
=
{
'no_bkg'
:
False
,
'vlim'
:
None
,
'show_axis'
:
False
,
'cmap'
:
'plasma'
,
'size_factor'
:
1
},
plot_dir
=
None
,
plot_config
=
None
,
dont_print_coun
t
=
False
):
plot_dir
=
None
,
plot_config
=
None
,
quie
t
=
False
):
"""Plot vector fields for all frames."""
# plotting directory
...
...
@@ -1104,7 +1106,7 @@ def plot_all_vector_fields(data_dir, df, data, field, plot_on_field=None, dim=3,
for
frame
in
np
.
sort
(
df
[
'frame'
].
unique
()):
frame
=
int
(
frame
)
fig
=
plot_vector_field
(
data_dir
,
df
,
data
,
field
,
frame
,
plot_on_field
=
plot_on_field
,
dim
=
dim
,
image
=
image
,
map_param
=
map_param
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
)
map_param
=
map_param
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
quiet
=
quiet
)
# append to stack
if
save_as_stack
:
...
...
@@ -1120,7 +1122,7 @@ def plot_all_vector_fields(data_dir, df, data, field, plot_on_field=None, dim=3,
def
plot_all_Voronoi
(
data_dir
,
df
,
data
,
show_local_area
=
True
,
df_mean
=
None
,
image
=
{
'image_fn'
:
None
,
't_dim'
:
None
,
'z_dim'
:
None
},
map_param
=
None
,
plot_dir
=
None
,
plot_config
=
None
,
dont_print_coun
t
=
False
):
map_param
=
None
,
plot_dir
=
None
,
plot_config
=
None
,
quie
t
=
False
):
"""
Plot Voronoi for all frames and calculate voronoi cell area.
"""
...
...
@@ -1176,7 +1178,7 @@ def plot_all_Voronoi(data_dir, df, data, show_local_area=True, df_mean = None,
for
frame
in
np
.
sort
(
df
[
'frame'
].
unique
()):
frame
=
int
(
frame
)
fig
=
plot_Voronoi
(
data_dir
,
df
,
frame
,
data
,
show_local_area
=
show_local_area
,
image
=
image
,
map_param
=
map_param
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
dont_print_count
=
dont_print_coun
t
)
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
quiet
=
quie
t
)
# append to stack
if
save_as_stack
:
...
...
track_analyzer/prepare.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
@@ -1201,11 +1201,9 @@ def load_config(data_dir, verbose=False):
if
f
.
endswith
(
'.csv'
):
out_dict
[
f
[:
-
4
]]
=
load_dict
(
osp
.
join
(
config_dir
,
f
))
else
:
if
verbose
:
print
(
"WARNING: config is not a directory. Config not loaded."
)
print
(
"WARNING: config is not a directory. Config not loaded."
)
else
:
if
verbose
:
print
(
"WARNING: no config directory. Config not loaded."
)
print
(
"WARNING: no config directory. Config not loaded."
)
return
out_dict
...
...
track_analyzer/scripts/__init__.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
track_analyzer/scripts/analyze_maps.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
@@ -35,7 +35,7 @@ from track_analyzer import calculate as tca
def
map_analysis
(
data_dir
,
data
=
None
,
image
=
None
,
refresh
=
False
,
parallelize
=
False
,
filters
=
None
,
plot_config
=
None
,
map_config
=
None
,
data_config
=
None
):
plot_config
=
None
,
map_config
=
None
,
data_config
=
None
,
quiet
=
False
):
"""Container method to plot a series of maps given by field_values. Manual vlim to colormap can be passed."""
map_dir
=
osp
.
join
(
data_dir
,
'map_analysis'
)
...
...
@@ -202,6 +202,8 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
# plot data
scalar_fields_
=
{
**
scalar_fields
,
**
vector_mean
}
# merge scalar data in one single dict
for
field
in
scalar_fields_
.
keys
():
if
not
quiet
:
print
(
"Plotting scalar fields..."
)
if
plot_config
[
'save_as_stack'
]:
plot_dir
=
sub_dir
else
:
# save series of images in a separate directory
...
...
@@ -211,8 +213,10 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
map_param_
[
'vlim'
]
=
scalar_fields_
[
field
][
'vlim'
]
if
'vlim'
in
scalar_fields_
[
field
].
keys
()
else
None
map_param_
[
'cmap'
]
=
scalar_fields_
[
field
][
'cmap'
]
if
'cmap'
in
scalar_fields_
[
field
].
keys
()
else
'plasma'
tpl
.
plot_all_scalar_fields
(
data_dir
,
df
,
field_data
,
field
,
image
=
image
,
map_param
=
map_param_
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
dont_print_count
=
False
)
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
quiet
=
quiet
)
for
field
in
vector_fields
.
keys
():
if
not
quiet
:
print
(
"Plotting vector fields..."
)
if
plot_config
[
'save_as_stack'
]:
plot_dir
=
sub_dir
else
:
# save series of images in a separate directory
...
...
@@ -222,7 +226,7 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
map_param_
[
'vlim'
]
=
vector_fields
[
field
][
'vlim'
]
tpl
.
plot_all_vector_fields
(
data_dir
,
df
,
field_data
,
field
,
image
=
image
,
plot_on_field
=
vector_fields
[
field
],
dim
=
3
,
map_param
=
map_param_
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
dont_print_count
=
False
)
quiet
=
quiet
)
return
df_list
...
...
@@ -253,9 +257,10 @@ def parse_args(args=None):
default
=
False
,
help
=
argparse
.
SUPPRESS
)
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
"store_true"
,
help
=
'Increase verbosity of output'
)
parser
.
add_argument
(
'-q'
,
'--quiet'
,
action
=
"store_true"
,
default
=
False
,
help
=
'do not display main log output'
)
parsed_args
=
parser
.
parse_args
(
args
)
...
...
@@ -271,6 +276,7 @@ def main(args=None):
data_dir
=
osp
.
realpath
(
parsed_args
.
data_dir
)
refresh
=
parsed_args
.
refresh
parallelize
=
parsed_args
.
parallelize
quiet
=
parsed_args
.
quiet
if
not
osp
.
exists
(
data_dir
):
raise
Exception
(
"ERROR: the passed data directory does not exist. Aborting..."
)
...
...
@@ -279,7 +285,7 @@ def main(args=None):
raise
Exception
(
"ERROR: the passed data directory is not a directory. Aborting..."
)
# Load config
config
=
tpr
.
load_config
(
data_dir
,
verbose
=
parsed_args
.
verbose
)
config
=
tpr
.
load_config
(
data_dir
)
# Check config
mandatory_config
=
[
"filters"
,
"plot_config"
,
"data_config"
]
...
...
@@ -297,6 +303,7 @@ def main(args=None):
map_analysis
(
data_dir
,
refresh
=
refresh
,
parallelize
=
parallelize
,
quiet
=
quiet
,
filters
=
config
[
"filters"
],
plot_config
=
config
[
"plot_config"
],
map_config
=
map_config
,
...
...
track_analyzer/scripts/analyze_tracks.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
@@ -35,7 +35,7 @@ from track_analyzer import calculate as tca
def
traj_analysis
(
data_dir
,
data
=
None
,
image
=
None
,
refresh
=
False
,
parallelize
=
False
,
filters
=
None
,
plot_config
=
None
,
traj_config
=
None
,
data_config
=
None
):
traj_config
=
None
,
data_config
=
None
,
quiet
=
False
):
"""Container method to run analysis related to cell trajectories."""
traj_dir
=
osp
.
join
(
data_dir
,
'traj_analysis'
)
...
...
@@ -158,18 +158,21 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
# plot trajectories
if
traj_config_
[
'run'
]:
print
(
"Plotting trajectories..."
)
if
not
quiet
:
print
(
"Plotting trajectories..."
)
tpl
.
plot_all_traj
(
data_dir
,
df
,
image
=
image
,
traj_parameters
=
traj_config_
,
parallelize
=
parallelize
,
dim
=
dim
,
plot_dir
=
sub_dir
,
plot_config
=
plot_config
)
dim
=
dim
,
plot_dir
=
sub_dir
,
plot_config
=
plot_config
,
quiet
=
quiet
)
if
total_traj_config
[
'run'
]:
print
(
"Plotting total trajectories"
)
if
not
quiet
:
print
(
"Plotting total trajectories"
)
tpl
.
plot_total_traj
(
data_dir
,
df
,
dim
=
dim
,
plot_dir
=
sub_dir
,
plot_config
=
plot_config
,
specific_config
=
total_traj_config
)
# MSD analysis
if
MSD_config
[
'run'
]:
print
(
"MSD analysis..."
)
if
not
quiet
:
print
(
"MSD analysis..."
)
df_prop
=
tpl
.
plot_all_MSD
(
data_dir
,
df
,
df_out
=
df_prop
,
fit_model
=
MSD_config
[
'MSD_model'
],
MSD_parameters
=
MSD_config
,
plot_config
=
plot_config
,
plot_dir
=
sub_dir
,
hue
=
hue
,
hue_order
=
hue_order
)
...
...
@@ -177,6 +180,8 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
# Voronoi analysis
if
voronoi_config
[
'run'
]:
if
not
quiet
:
print
(
"Voronoi analysis..."
)
vor_data
=
tca
.
compute_all_Voronoi
(
data_dir
,
df
,
outdir
=
sub_dir
,
compute_local_area
=
voronoi_config
[
'compute_local_area'
],
area_threshold
=
voronoi_config
[
'area_threshold'
],
df_mean
=
df_prop
)
# update csv files with area data
...
...
@@ -184,13 +189,15 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
df
.
to_csv
(
csv_fn
)
if
voronoi_config
[
'plot'
]:
if
len
(
df_list
)
>
1
and
subset_analysis
==
'together'
:
print
(
"WARNING: there is no color code to identify subsets in Voronoi diagram plots"
)
if
plot_config
[
'save_as_stack'
]:
plot_dir
=
sub_dir
else
:
# save series of images in a separate directory
plot_dir
=
osp
.
join
(
sub_dir
,
'voronoi'
)
tpr
.
safe_mkdir
(
plot_dir
)
tpl
.
plot_all_Voronoi
(
data_dir
,
df
,
vor_data
,
show_local_area
=
voronoi_config
[
'show_local_area'
],
image
=
image
,
map_param
=
voronoi_config
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
dont_print_count
=
False
)
map_param
=
voronoi_config
,
plot_dir
=
plot_dir
,
plot_config
=
plot_config
,
quiet
=
quiet
)
if
hist_config
[
'run'
]:
fn
=
osp
.
join
(
config_dir
,
'hist_config.csv'
)
...
...
@@ -198,14 +205,16 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
if
'var_list'
in
hist_config
.
keys
():
if
len
(
hist_config
[
'var_list'
])
>
0
:
print
(
"Plotting parameters histograms..."
)
if
not
quiet
:
print
(
"Plotting parameters histograms..."
)
for
p
in
hist_config
[
'var_list'
]:
tpl
.
plot_param_hist
(
data_dir
,
p
,
df
,
plot_config
=
plot_config
,
plot_dir
=
sub_dir
,
hue
=
hue
,
hue_order
=
hue_order
)
if
'mean_var_list'
in
hist_config
.
keys
():
if
len
(
hist_config
[
'mean_var_list'
])
>
0
:
print
(
"Plotting whole-track histograms..."
)
if
not
quiet
:
print
(
"Plotting whole-track histograms..."
)
for
p
in
hist_config
[
'mean_var_list'
]:
tpl
.
plot_param_hist
(
data_dir
,
p
,
df_prop
,
plot_config
=
plot_config
,
plot_dir
=
sub_dir
,
prefix
=
'track_'
,
hue
=
hue
,
hue_order
=
hue_order
)
...
...
@@ -216,7 +225,8 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
if
'couple_list'
in
scatter_config
.
keys
():
if
len
(
scatter_config
[
'couple_list'
])
>
0
:
print
(
"Plotting couples of parameters..."
)
if
not
quiet
:
print
(
"Plotting couples of parameters..."
)
for
param_vs_param
in
scatter_config
[
'couple_list'
]:
x_param
,
y_param
=
param_vs_param
tpl
.
plot_param_vs_param
(
data_dir
,
x_param
,
y_param
,
df
,
plot_dir
=
sub_dir
,
plot_config
=
plot_config
,
...
...
@@ -224,7 +234,8 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
if
'mean_couple_list'
in
scatter_config
.
keys
():
if
len
(
scatter_config
[
'mean_couple_list'
])
>
0
:
print
(
"Plotting couples of whole-track parameters..."
)
if
not
quiet
:
print
(
"Plotting couples of whole-track parameters..."
)
for
param_vs_param
in
scatter_config
[
'mean_couple_list'
]:
x_param
,
y_param
=
param_vs_param
tpl
.
plot_param_vs_param
(
data_dir
,
x_param
,
y_param
,
df_prop
,
plot_dir
=
sub_dir
,
plot_config
=
plot_config
,
...
...
@@ -259,9 +270,10 @@ def parse_args(args=None):
default
=
False
,
help
=
argparse
.
SUPPRESS
)
parser
.
add_argument
(
'-v'
,
'--verbose'
,
action
=
"store_true"
,
help
=
'Increase verbosity of output'
)
parser
.
add_argument
(
'-q'
,
'--quiet'
,
action
=
"store_true"
,
default
=
False
,
help
=
'do not display main log output'
)
parsed_args
=
parser
.
parse_args
(
args
)
...
...
@@ -277,6 +289,7 @@ def main(args=None):
data_dir
=
osp
.
realpath
(
parsed_args
.
data_dir
)
refresh
=
parsed_args
.
refresh
parallelize
=
parsed_args
.
parallelize
quiet
=
parsed_args
.
quiet
if
not
osp
.
exists
(
data_dir
):
raise
Exception
(
"ERROR: the passed data directory does not exist. Aborting..."
)
...
...
@@ -285,7 +298,7 @@ def main(args=None):
raise
Exception
(
"ERROR: the passed data directory is not a directory. Aborting..."
)
# Load config
config
=
tpr
.
load_config
(
data_dir
,
verbose
=
parsed_args
.
verbose
)
config
=
tpr
.
load_config
(
data_dir
)
# Check config
mandatory_config
=
[
"filters"
,
"plot_config"
,
"data_config"
]
...
...
@@ -303,6 +316,7 @@ def main(args=None):
traj_analysis
(
data_dir
,
refresh
=
refresh
,
parallelize
=
parallelize
,
quiet
=
quiet
,
filters
=
config
[
"filters"
],
plot_config
=
config
[
"plot_config"
],
traj_config
=
traj_config
,
...
...
track_analyzer/scripts/compare_datasets.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
track_analyzer/synthetic_data.py
View file @
fba7cfd7
...
...
@@ -3,7 +3,7 @@
# Authors: Arthur Michaut #
# Copyright 2016-2019 Harvard Medical School and Brigham and #
# Women's Hospital #
# Copyright 2019-202
1
Institut Pasteur and CNRS–UMR3738 #
# Copyright 2019-202
2
Institut Pasteur and CNRS–UMR3738 #
# See the COPYRIGHT file for details #
# #
# This file is part of Track Analyzer package. #
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment