Commit 5b543bd2 authored by amichaut's avatar amichaut
Browse files

integrated voronoi and tested

parent d832900d
Pipeline #55333 passed with stages
in 16 seconds
This diff is collapsed.
This diff is collapsed.
......@@ -169,19 +169,27 @@ def compute_track_prop(df, dimensions=['x', 'y', 'z']):
groups = df.groupby('track')
# colmuns to average
scaled_dimensions = [dim + '_scaled' for dim in dimensions]
vel = ['v' + dim for dim in dimensions]
acc = ['a' + dim for dim in dimensions]
columns = ['track', 'track_length', 't'] + dimensions + scaled_dimensions + vel + acc + ['v', 'a']
mean_col = ['t'] + dimensions + scaled_dimensions + vel + acc + ['v', 'a']
# all columns
columns = ['track', 'track_length'] + mean_col
if 'subset' in df.columns:
columns.append('subset')
df_out = pd.DataFrame(columns=columns)
# average
for i, track in enumerate(df['track'].unique()):
traj = groups.get_group(track)
track_length = traj['t'].max() - traj['t'].min()
val = [track, track_length]
for col in columns[2:]:
for col in mean_col:
val.append(traj[col].mean())
if 'subset' in df.columns:
val.append(traj['subset'].values[0])
df_out.loc[i, columns] = val
return df_out
......@@ -226,7 +234,7 @@ def interpolate_field(data_dir, df, groups, grids, frame, field_values=['vx', 'v
field_dict = {k: [] for k in field_values}
coord_list = list(df.columns)
for non_coord in ['track', 'frame', 't', 'input_track_id', 'Unnamed: 0']:
for non_coord in ['track', 'frame', 't', 'input_track_id', 'Unnamed: 0', 'subset']:
if non_coord in coord_list:
coord_list.remove(non_coord)
......@@ -481,7 +489,7 @@ def get_obj_persistence_length(track_groups, track, traj=None, save_plot=False,
return np.nan
def compute_Voronoi(df, frame, groups=None, compute_local_area=True, lengthscale=1., area_threshold=3):
def compute_Voronoi(df, frame, groups=None, compute_local_area=True, lengthscale=1., area_threshold=3, save_to_df=True):
"""
Compute Voronoi tesselation at a given frame. Optional: compute Voronoi cell area
:param df: trajectory dataframe
......@@ -496,6 +504,8 @@ def compute_Voronoi(df, frame, groups=None, compute_local_area=True, lengthscale
:type lengthscale: float
:param area_threshold: exclusion threshold, above a multiple of area median
:type area_threshold: float or int
:param save_to_df: save areas to trajectory dataframe
:type save_to_df: bool
:return: dict of Voronoi tesselation and areas if computed
:rtype: dict
"""
......@@ -504,31 +514,38 @@ def compute_Voronoi(df, frame, groups=None, compute_local_area=True, lengthscale
group = groups.get_group(frame)
points = group[['x', 'y']].values
vor = Voronoi(points)
# compute voronoi cells area
if compute_local_area:
areas = np.zeros(vor.npoints)
# point_region matches input points with voronoi region index
for pt_id, reg_num in enumerate(vor.point_region):
indices = vor.regions[reg_num]
if -1 in indices: # some regions can be opened
areas[pt_id] = np.nan
else:
area_ = ConvexHull(vor.vertices[indices]).volume # volume in 2D = area (in px^2)
areas[pt_id] = area_*lengthscale**2 # scale area
# needs at least 4 points to compute a Voronoi tesselation
if points.shape[0] >= 4:
if area_threshold is not None:
areas_nonan = areas[~np.isnan(areas)]
median = np.median(areas_nonan)
mask = areas > area_threshold * median # remove areas above threshold
areas[mask] = np.nan
vor = Voronoi(points)
# save area in df
df.loc[group.index, 'local_area'] = areas
else:
# compute voronoi cells area
if compute_local_area:
areas = np.zeros(vor.npoints)
# point_region matches input points with voronoi region index
for pt_id, reg_num in enumerate(vor.point_region):
indices = vor.regions[reg_num]
if -1 in indices: # some regions can be opened
areas[pt_id] = np.nan
else:
area_ = ConvexHull(vor.vertices[indices]).volume # volume in 2D = area (in px^2)
areas[pt_id] = area_*lengthscale**2 # scale area
if area_threshold is not None:
areas_nonan = areas[~np.isnan(areas)]
median = np.median(areas_nonan)
mask = areas > area_threshold * median # remove areas above threshold
areas[mask] = np.nan
else:
areas = None
else:
vor = None
areas = None
# save area in df
if save_to_df:
df.loc[group.index, 'area'] = areas
return {'vor': vor, 'areas': areas}
def compute_all_Voronoi(data_dir, df, outdir=None, compute_local_area=True, area_threshold=3):
......
......@@ -98,11 +98,7 @@ def plot_cmap(plot_dir, label, cmap, vmin, vmax, plot_config=None):
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={'show_tail': True, 'color_code': 'z', 'hide_labels': True, 'lab_size': 6,
'no_bkg': False,
'size_factor': 1., 'plot3D': False, 'z_lim': None, 'show_axis': False, 'elevation': None,
'angle': None}):
show_plot=False, dim=3, plot_config=None,traj_parameters=None):
"""
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')
......@@ -114,6 +110,24 @@ def plot_traj(df, frame, data_dir, groups=None, image={'image_fn': None, 't_dim'
# get config parameters
plot_config = make_plot_config() if plot_config is None else plot_config
if traj_parameters is None:
traj_parameters = {'color_code': 'z', # color code: 'z', 'ROI', 'random', 'none'
'cmap': 'plasma', # colormap to be used if color_code is 'z'
'cmap_lim': None,
# pass custom colormap limits (useful for getting coherent boundaries for all frames)
'show_tail': True, # show trajectory tail
'hide_labels': True, # hide trajectory ID
'lab_size': 6, # label size in points if hide_labels is False
'no_bkg': False, # don't show background image if an image is passed
'size_factor': 1., # to multiply the default size of markers and lines
'show_axis': False, # to show the plot axes (by default just image)
'plot3D': False, # plot in 3D !! Not supportes anymore !!
'elevation': None, # 3D paramater !! Not supportes anymore !!
'angle': None, # 3D paramater !! Not supportes anymore !!
'subset_order': None, # if color code is ROI, order of ROI in color cycle
}
color_list = plot_config['color_list']
show_tail = traj_parameters['show_tail']
color_code = traj_parameters['color_code']
......@@ -129,6 +143,7 @@ def plot_traj(df, frame, data_dir, groups=None, image={'image_fn': None, 't_dim'
lab_size = traj_parameters['lab_size']
invert_yaxis = plot_config['invert_yaxis']
# get image size
info = tpr.get_info(data_dir)
image_size = [info['image_width'], info['image_height']]
......@@ -451,7 +466,7 @@ def plot_Voronoi(data_dir, df, frame, data, show_local_area=True,
no_bkg = True
bkgd = tpr.get_background(image=image, frame=frame, df=df, no_bkg=no_bkg,
image_size=image_size, axis_on=show_axis,dpi=plot_config['dpi'])
image_size=image_size, axis_on=show_axis, dpi=plot_config['dpi'])
fig = bkgd['fig']
ax = bkgd['ax']
xmin = bkgd['xmin']
......@@ -462,18 +477,19 @@ def plot_Voronoi(data_dir, df, frame, data, show_local_area=True,
# plot tesselation
vor = data[frame]['vor']
voronoi_plot_2d(vor, show_points=False, show_vertices=False, ax=ax)
# plot local area on top
if show_local_area:
areas = data[frame]['areas']
if areas is not None:
for pt_id, reg_num in enumerate(vor.point_region):
indices = vor.regions[reg_num]
area = areas[pt_id]
if not np.isnan(area):
color = tpr.get_cmap_color(area, cmap, vmin=vlim[0], vmax=vlim[1])
ax.fill(*zip(*vor.vertices[indices]), color=color, alpha=0.5)
if vor is not None:
voronoi_plot_2d(vor, show_points=False, show_vertices=False, ax=ax)
# plot local area on top
if show_local_area:
areas = data[frame]['areas']
if areas is not None:
for pt_id, reg_num in enumerate(vor.point_region):
indices = vor.regions[reg_num]
area = areas[pt_id]
if not np.isnan(area):
color = tpr.get_cmap_color(area, cmap, vmin=vlim[0], vmax=vlim[1])
ax.fill(*zip(*vor.vertices[indices]), color=color, alpha=0.5)
if show_axis:
ax.grid(False)
......@@ -878,6 +894,7 @@ def plot_all_traj(data_dir, df, image={'image_fn': None, 't_dim': None, 'z_dim':
for sub in df['subset'].unique():
if sub not in subset_order: # if missing subset in subset_oder, adding it
subset_order.append(sub)
subset_order = list(subset_order) # convert to list to use index method
df['subset_order'] = df['subset'].apply(lambda s: subset_order.index(s)) # column with indices in subset_order
# # ensure 'z' is not color code for 2D data
......@@ -1039,12 +1056,21 @@ def plot_all_MSD(data_dir, df=None, df_out=None, fit_model="biased_diff", msd_al
if refresh:
track_groups = df.groupby(['track'])
track_list = df['track'].unique()
msd_list = []
for track in track_list:
msd = plot_MSD(data_dir, track=track, track_groups=track_groups, df=df, df_out=df_out, fit_model=fit_model,
dim=dim, save_plot=plot_single_MSD, fitrange=fitrange, plot_dir=plot_dir,
plot_config=plot_config, logx=logx, logy=logy)
msd['track'] = track
msd_all = pd.concat([msd_all, msd])
# get subset if exists
if 'subset' in df.columns:
t = track_groups.get_group(track)
subset = t['subset'].values[0]
msd['subset'] = subset
msd_list.append(msd)
#concatenate
msd_all = pd.concat(msd_list)
# plot all
if plot_all_MSD:
......@@ -1132,6 +1158,7 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
color_list = plot_config['color_list']
invert_yaxis = plot_config['invert_yaxis']
#initialize config if None
if specific_config is None:
specific_config = {'dont_center': False,
'hide_labels': False,
......@@ -1140,9 +1167,11 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
'label_size': 6,
'color_code': 'random',
'cmap': 'plasma',
'z_lim': None
'cmap_lim': None,
'subset_order': None,
}
# unpack config
dont_center = specific_config['dont_center']
hide_labels = specific_config['hide_labels']
set_axis_lim = specific_config['set_axis_lim']
......@@ -1150,25 +1179,49 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
label_size = specific_config['label_size']
color_code = specific_config['color_code']
cmap = specific_config['cmap']
z_lim = specific_config['z_lim']
cmap_lim = specific_config['cmap_lim']
subset_order = specific_config['subset_order']
# get info
info = tpr.get_info(data_dir)
# saving directory
if plot_dir is None:
plot_dir = osp.join(data_dir, 'centered_traj')
tpr.safe_mkdir(plot_dir)
# group by tracks
track_groups = df.groupby(['track'])
# color code
if color_code == 'z' and dim == 3:
if z_lim is None:
z_lim = [df['z_scaled'].min(), df['z_scaled'].max()]
if cmap_lim is None:
cmap_lim = [df['z_scaled'].min(), df['z_scaled'].max()]
if len(z_lim) == 2:
plot_cmap(plot_dir, tpr.make_param_label('z', l_unit=info["length_unit"]), cmap, z_lim[0], z_lim[1])
if len(cmap_lim) == 2:
plot_cmap(plot_dir, tpr.make_param_label('z', l_unit=info["length_unit"]), cmap, cmap_lim[0], cmap_lim[1])
elif color_code == 't':
if cmap_lim is None:
cmap_lim = [df['t'].min(), df['t'].max()]
if len(cmap_lim) == 2:
plot_cmap(plot_dir, tpr.make_param_label('t', l_unit=info["time_unit"]), cmap, cmap_lim[0], cmap_lim[1])
elif color_code == 'ROI':
if 'subset' in df.columns:
# check subset order
if subset_order is None:
subset_order = df['subset'].unique()
else:
for sub in df['subset'].unique():
if sub not in subset_order: # if missing subset in subset_oder, adding it
subset_order.append(sub)
subset_order = list(subset_order) # convert to list to use index method
df['subset_order'] = df['subset'].apply(lambda s: subset_order.index(s)) # column with indices in subset_order
# ensure 'z' is not color code for 2D data
if dim == 2 and color_code == 'z':
elif dim == 2 and color_code == 'z':
color_code == 'random'
fig, ax = plt.subplots(1, 1, figsize=plot_config['figsize'])
......@@ -1193,9 +1246,8 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
elif color_code == "none":
colors = color_list[0]
elif color_code == "ROI":
if 'subset' in df.columns:
subset = traj.loc[0, 'subset']
colors = color_list[subset % len(color_list)]
if 'subset_order' in df.columns:
colors = color_list[traj['subset_order'].values[0] % len(color_list)]
else:
colors = color_list[0] # if color_coded by subset but there's none, use only one color
else:
......
......@@ -75,21 +75,12 @@ def make_map_config(data_dir=None, export_config=True):
}
}
# config of voronoi plot
voronoi = {'vlim': None, # value limits to display on the color map
'cmap': "plasma", # color map
'compute_local_area': True, # compute voronoi cell area
'show_local_area': True, # show voronoi cell area
'area_threshold': 3, # exclude areas above this multiple of area median
}
# package all in a dict
config = {'grid_param': grid_param,
'map_param': map_param,
'scalar_fields': scalar_fields,
'vector_fields': vector_fields,
'vector_mean': vector_mean,
'voronoi': voronoi,
}
if export_config:
......@@ -114,7 +105,6 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
tpr.safe_mkdir(map_dir)
# Get data
data = tpr.get_data(data_dir, refresh=refresh) if data is None else data
image = tpr.get_image(data_dir) if image is None else image
......@@ -123,14 +113,13 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
lengthscale = data['lengthscale']
# Get config
plot_config = tpl.make_plot_config() if plot_config is None else plot_config
map_config_default = make_map_config(data_dir=data_dir, export_config=False)
map_config = map_config_default if map_config is None else map_config
# check that all configs are in map_config, if not load default
for key in ["grid_param", "map_param", "scalar_fields", "vector_fields", "vector_mean", "voronoi"]:
for key in ["grid_param", "map_param", "scalar_fields", "vector_fields", "vector_mean"]:
if key not in map_config.keys():
map_config[key] = map_config_default[key]
......@@ -139,15 +128,19 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
scalar_fields = map_config["scalar_fields"]
vector_fields = map_config["vector_fields"]
vector_mean = map_config["vector_mean"]
voronoi = map_config["voronoi"]
### Filter data
filters = tpr.init_filters() if filters is None else filters
filters = [filters] if type(filters) is dict else filters # if only one set of filters make it a list
df_list, ROI_list = tpr.select_sub_data(df, image=image, filters=filters)
### Make grid
# Filter data
filters = tpr.init_filters(data_dir=data_dir, export_to_config=True) if filters is None else filters
subset_analysis = filters['subset'] # how to deal with subsets
filters_ = filters['filters_list']
df = tpr.select_sub_data(df, filters=filters_)
if subset_analysis == 'together':
print("WARNING: subsets won't be plotted in different colors in maps if plotted together")
df_list = [df] # a single df is kept
elif subset_analysis == 'separately':
df_list = [df[df['subset'] == sub] for sub in df['subset'].unique()] # a list of df filtered by subset
# Make grid
image_size = [image['image_size'][1], image['image_size'][0]] # image width,image height in px
grids = tpr.make_grid(image_size,
x_num=grid_param['x_num'],
......@@ -159,9 +152,13 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
plot_grid=grid_param['plot_grid'],
save_plot_fn=osp.join(map_dir, 'grids{}'.format(plot_config['format'])))
# compute fields
# Compute fields
for i, df in enumerate(df_list):
dir_name = '_' + filters[i]['name'] if filters[i]['name'] != '' else ''
# name subset directory
dir_name = ''
if subset_analysis == 'separately':
subset_name = df['subset'].values[0]
dir_name = '_' + subset_name if subset_name != '' else ''
dir_name_ = '{}{}'.format(len(tpr.listdir_nohidden(map_dir)) + 1, dir_name)
print(r"Analyzing subset {} ".format(i + 1, dir_name_))
......@@ -172,6 +169,13 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
# export data
csv_fn = osp.join(sub_dir, 'all_data.csv')
df.to_csv(csv_fn)
config_dir = osp.join(sub_dir, 'config')
tpr.safe_mkdir(config_dir)
fn = osp.join(config_dir, 'filters.csv')
tpr.write_dict(filters_[i], fn)
for key in map_config.keys():
fn = osp.join(config_dir, key + '.csv')
tpr.write_dict(map_config[key], fn)
# list required fields to interpolate
all_fields = list(set(list(scalar_fields.keys()) + list(vector_fields.keys()) + list(vector_mean.keys())))
......@@ -201,9 +205,6 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
dimensions=vector_mean[mf]['dimensions'],
export_field=map_param['export_field'], outdir=sub_dir)
vor_data = tca.compute_all_Voronoi(data_dir, df, outdir=sub_dir,compute_local_area=voronoi['compute_local_area'],
area_threshold=voronoi['area_threshold'])
# plot data
scalar_fields_ = {**scalar_fields, **vector_mean} # merge scalar data in one single dict
for field in scalar_fields_.keys():
......@@ -223,14 +224,6 @@ def map_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fal
dim=3, map_param=map_param_, plot_dir=plot_dir, plot_config=plot_config,
dont_print_count=False)
map_param_ = dict(map_param)
map_param_['vlim'] = voronoi['vlim']
map_param_['cmap'] = voronoi['cmap']
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['show_local_area'], image=image,
map_param=map_param_, plot_dir=plot_dir, plot_config=plot_config, dont_print_count=False)
return df_list
......@@ -296,7 +289,7 @@ def main(args=None):
# get map_config
map_config = {}
for key in ["grid_param", "map_param", "scalar_fields", "vector_fields", "vector_mean", "voronoi"]:
for key in ["grid_param", "map_param", "scalar_fields", "vector_fields", "vector_mean"]:
if key in config.keys():
map_config[key] = config[key]
......
......@@ -48,9 +48,9 @@ def make_traj_config(data_dir=None, export_config=True):
'no_bkg': False, # don't show background image if an image is passed
'size_factor': 1., # to multiply the default size of markers and lines
'show_axis': False, # to show the plot axes (by default just image)
'plot3D': False, # plot in 3D
'elevation': None, # 3D paramater
'angle': None, # 3D paramater
'plot3D': False, # plot in 3D !! Not supportes anymore !!
'elevation': None, # 3D paramater !! Not supportes anymore !!
'angle': None, # 3D paramater !! Not supportes anymore !!
'subset_order': None, # if color code is ROI, order of ROI in color cycle
}
......@@ -87,15 +87,30 @@ def make_traj_config(data_dir=None, export_config=True):
'equal_axis': True, # set x and y axes' scaling equal
'color_code': 'random', # color code: 'z', 'ROI', 'random', 'none'
'cmap': 'plasma', # colormap to be used if color_code is 'z'
'z_lim': None # z limits to be used if color_code is 'z'
'cmap_lim': None, # pass custom colormap limits
'subset_order': None, # if color code is ROI, order of ROI in color cycle
}
# config of voronoi plot
voronoi = {'run': True, # run analysis
'plot': True, # plot diagram
'vlim': None, # value limits to display on the color map
'cmap': "plasma", # color map
'compute_local_area': True, # compute voronoi cell area
'show_local_area': True, # show voronoi cell area
'area_threshold': 3, # exclude areas above this multiple of area median
'no_bkg': False, # don't show background image if an image is passed
'size_factor': 1., # to multiply the default size of lines !! Not implemented yet !!
'show_axis': False, # to show the plot axes (by default just image)
}
# package all in a dict
config = {'traj_config_': traj_config_,
'MSD_config': MSD_config,
'scatter_config': scatter_config,
'hist_config': hist_config,
'total_traj_config': total_traj_config
'total_traj_config': total_traj_config,
'voronoi_config': voronoi,
}
if export_config:
......@@ -119,8 +134,7 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
traj_dir = osp.join(data_dir, 'traj_analysis')
tpr.safe_mkdir(traj_dir)
### Get data
# Get data
data = tpr.get_data(data_dir, refresh=refresh) if data is None else data
image = tpr.get_image(data_dir) if image is None else image
......@@ -128,15 +142,14 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
dim = data['dim']
dimensions = data['dimensions']
### Get config
# Get config
plot_config = tpl.make_plot_config() if plot_config is None else plot_config
traj_config_default = make_traj_config(data_dir=data_dir, export_config=False)
traj_config = traj_config_default if traj_config is None else traj_config
# check that all configs are in traj_confign, if not load default
for key in ["traj_config_", "MSD_config", "scatter_config", "hist_config", "total_traj_config"]:
for key in ["traj_config_", "MSD_config", "scatter_config", "hist_config", "total_traj_config", "voronoi_config"]:
if key not in traj_config.keys():
traj_config[key] = traj_config_default[key]
......@@ -145,8 +158,9 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
scatter_config = traj_config["scatter_config"]
hist_config = traj_config["hist_config"]
total_traj_config = traj_config["total_traj_config"]
voronoi_config = traj_config["voronoi_config"]
### Filter data
# Filter data
filters = tpr.init_filters(data_dir=data_dir, export_to_config=True) if filters is None else filters
subset_analysis = filters['subset'] # how to deal with subsets
filters_ = filters['filters_list']
......@@ -159,7 +173,7 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
elif subset_analysis == 'separately':
df_list = [df[df['subset'] == sub] for sub in df['subset'].unique()] # a list of df filtered by subset
### Run analysis
# Run analysis
for i, df in enumerate(df_list):
# name subset directory
dir_name = ''
......@@ -174,7 +188,6 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
tpr.safe_mkdir(sub_dir)
# export data
# export filtered positions
csv_fn = osp.join(sub_dir, 'all_data.csv')
df.to_csv(csv_fn)
......@@ -201,15 +214,24 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
if subset_analysis == 'together':
hue = 'subset'
hue_order = df['subset'].unique() if filters['subset_order'] is None else filters['subset_order']
traj_config_['subset_order'] = hue_order
else:
hue = None
hue_order = None
# plot trajectories
if traj_config_['run']:
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)
if total_traj_config['run']:
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...")
MSD_dir = tpr.safe_mkdir(osp.join(sub_dir, 'MSD'))
......@@ -218,6 +240,16 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
hue_order=hue_order)
df_prop.to_csv(mean_fn)
# Voronoi analysis
if voronoi_config['run']:
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'])
if voronoi_config['plot']:
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)
if hist_config['run']:
if len(hist_config['var_list']) > 0:
<