Commit c67913b9 authored by amichaut's avatar amichaut
Browse files

changed plotting parameters dont_center>center_origin and ROI>group

parent df76a0f3
This diff is collapsed.
......@@ -122,7 +122,7 @@ 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'
traj_parameters = {'color_code': 'z', # color code: 'z', 'group', '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)
......@@ -135,7 +135,7 @@ def plot_traj(df, frame, data_dir, groups=None, image={'image_fn': None, 't_dim'
'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
'subset_order': None, # if color-code is group, order of group in color cycle
}
......@@ -213,7 +213,7 @@ def plot_traj(df, frame, data_dir, groups=None, image={'image_fn': None, 't_dim'
elif color_code == "t":
colors = tpr.get_cmap_color(t, cmap, vmin=cmap_lim[0], vmax=cmap_lim[1])
elif color_code == "ROI":
elif color_code == "group":
# check there are subsets in df
if 'subset' in group.columns:
colors = [color_list[i % len(color_list)] for i in group['subset_order'].values] # if too many colors repeat cycle
......@@ -255,7 +255,7 @@ def plot_traj(df, frame, data_dir, groups=None, image={'image_fn': None, 't_dim'
colors = tpr.get_cmap_color(Z, cmap, vmin=cmap_lim[0], vmax=cmap_lim[1])
elif color_code == "t":
colors = tpr.get_cmap_color(t, cmap, vmin=cmap_lim[0], vmax=cmap_lim[1])
elif color_code == "ROI":
elif color_code == "group":
if 'subset' in traj.columns:
colors = color_list[traj['subset_order'].values[0] % len(color_list)]
else:
......@@ -914,7 +914,7 @@ def plot_all_traj(data_dir, df, image={'image_fn': None, 't_dim': None, 'z_dim':
traj_parameters['cmap_lim'][1])
# make a colmuns of indices to be used for color_cylce
elif color_code == "ROI":
elif color_code == "group":
subset_order = traj_parameters['subset_order']
if 'subset' in df.columns:
# check subset order
......@@ -1192,7 +1192,7 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
#initialize config if None
if specific_config is None:
specific_config = {'dont_center': False,
specific_config = {'center_origin': False,
'hide_labels': False,
'set_axis_lim': None,
'equal_axis': True,
......@@ -1204,7 +1204,7 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
}
# unpack config
dont_center = specific_config['dont_center']
center_origin = specific_config['center_origin']
hide_labels = specific_config['hide_labels']
set_axis_lim = specific_config['set_axis_lim']
equal_axis = specific_config['equal_axis']
......@@ -1240,7 +1240,7 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
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':
elif color_code == 'group':
if 'subset' in df.columns:
# check subset order
if subset_order is None:
......@@ -1266,7 +1266,7 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
y = traj['y_scaled'].values
if dim == 3:
z = traj['z_scaled'].values
if not dont_center:
if center_origin:
traj['x_scaled'] -= x0
traj['y_scaled'] -= y0
......@@ -1277,7 +1277,7 @@ def plot_total_traj(data_dir, df, dim=3, plot_dir=None, plot_fn=None, plot_confi
colors = color_list[i % len(color_list)]
elif color_code == "none":
colors = color_list[0]
elif color_code == "ROI":
elif color_code == "group":
if 'subset_order' in df.columns:
colors = color_list[traj['subset_order'].values[0] % len(color_list)]
else:
......
......@@ -1221,7 +1221,7 @@ def make_traj_config(data_dir=None, export_config=True):
"""
traj_config_ = {'run': True, # run plot_traj
'color_code': 'z', # color code: 'z', 'ROI', 'random', 'none'
'color_code': 'z', # color code: 'z', 'group', '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)
......@@ -1234,7 +1234,7 @@ def make_traj_config(data_dir=None, export_config=True):
'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
'subset_order': None, # if color_code is group, order of group in color cycle
}
MSD_config = {'run': True, # run plot_all_MSD
......@@ -1265,13 +1265,13 @@ def make_traj_config(data_dir=None, export_config=True):
total_traj_config = {'run': True, # run plot_centered_traj
'hide_labels': False, # hide trajectory ID
'label_size': 5, # label size in points if hide_labels is False
'dont_center': False, # to keep initial position at its true position
'center_origin': True, # to center origin of all trajectories
'set_axis_lim': None, # custom axis limites: [xmin,xmax,ymin,ymax]
'equal_axis': True, # set x and y axes' scaling equal
'color_code': 'random', # color code: 'z', 'ROI', 'random', 'none'
'color_code': 'random', # color code: 'z', 'group', 'random', 'none'
'cmap': 'plasma', # colormap 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
'subset_order': None, # if color_code is group, order of group in color cycle
}
# config of voronoi plot
......
......@@ -89,8 +89,8 @@ def traj_analysis(data_dir, data=None, image=None, refresh=False, parallelize=Fa
if subset_analysis == 'together':
df_list = [df] # a single df is kept
# force color coding trajectory plotting
traj_config_['color_code'] = 'ROI'
total_traj_config['color_code'] = 'ROI'
traj_config_['color_code'] = 'group'
total_traj_config['color_code'] = 'group'
elif subset_analysis == 'separately':
df_list = [df[df['subset'] == sub] for sub in df['subset'].unique()] # a list of df filtered by subset
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment