Commit b82f544b authored by amichaut's avatar amichaut
Browse files

minor performance improvements

parent 0e14b752
......@@ -141,7 +141,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "29221b9fb7954fcabe817ee73c23d326",
"model_id": "20c7a503a6a846af99ca91335a0e25f0",
"version_major": 2,
"version_minor": 0
},
......@@ -155,7 +155,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "289704b2d5f040ef861e2de73e45d110",
"model_id": "77bc9612106143ec8e52cfe43b122908",
"version_major": 2,
"version_minor": 0
},
......@@ -169,7 +169,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "570beba3146d4978afe4874c915e506e",
"model_id": "a54f05446fc7460ba73a6dd4fbbb8bb4",
"version_major": 2,
"version_minor": 0
},
......@@ -219,7 +219,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f473abafd6ad438f86dffbefb6c8c458",
"model_id": "db31dc98d84947f8a3a362e685f26b1c",
"version_major": 2,
"version_minor": 0
},
......@@ -285,7 +285,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3b83147d5e5c47a49e59bb3c32d6cdda",
"model_id": "ab8199bb4597420b8b35eebba6009fa8",
"version_major": 2,
"version_minor": 0
},
......@@ -311,7 +311,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c2a49ea6ab0e4646a5a13ae94b815827",
"model_id": "5b2f2e5ed7e446e1960687e7638f59f4",
"version_major": 2,
"version_minor": 0
},
......@@ -713,7 +713,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c6e4654722cb41e3b041036bd538827d",
"model_id": "9aa5dadd022c4f6680739f0181662c7b",
"version_major": 2,
"version_minor": 0
},
......@@ -727,7 +727,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b65f58af45a043e5a2c478a9621812aa",
"model_id": "81a41049669742e8a5ea85de18b79b6c",
"version_major": 2,
"version_minor": 0
},
......@@ -741,7 +741,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "86f7df713c69406b9e51d7ce6259c945",
"model_id": "d599872f541b4fee94a15e40d0495c44",
"version_major": 2,
"version_minor": 0
},
......@@ -767,7 +767,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f01554db238c49e2bae5a1fd1b7a82bd",
"model_id": "ccc323e61d984d7a9f7a0dfddac6d892",
"version_major": 2,
"version_minor": 0
},
......@@ -793,7 +793,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6c9dfbd8a1e2433889bd27e84f2276e0",
"model_id": "6d5fdd234ed54ce7b418f3c9108abb00",
"version_major": 2,
"version_minor": 0
},
......@@ -819,7 +819,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ee94186e6b5b4dbc98d5c4e8e921f744",
"model_id": "faad37ea1bbf4ef8a687f540e542a298",
"version_major": 2,
"version_minor": 0
},
......@@ -845,7 +845,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1a5d9b83b8f846088c3529d50949a631",
"model_id": "8cfc7f63cccd48058a235a88e114435a",
"version_major": 2,
"version_minor": 0
},
......@@ -871,7 +871,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1ca3982dfebf4ca493efe64d657210b9",
"model_id": "022f08e20fdf490c8e054577c950d630",
"version_major": 2,
"version_minor": 0
},
......@@ -1056,7 +1056,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "94969e61438b417f96d854249142da17",
"model_id": "d0c985fd205c44cdb0d3b988827520f1",
"version_major": 2,
"version_minor": 0
},
......@@ -1109,7 +1109,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "78d6907065344e6791908e1776c005fc",
"model_id": "6800e891e81d421381d8137dabab267d",
"version_major": 2,
"version_minor": 0
},
......@@ -1147,7 +1147,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b199795e843b4f9d993c3990a97f1e83",
"model_id": "f6a09c7f213e41049710c36498b7a21d",
"version_major": 2,
"version_minor": 0
},
......@@ -1172,7 +1172,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 16,
"metadata": {
"scrolled": false
},
......@@ -1204,7 +1204,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ac2a09bee650494e9aa1d80ab29a571d",
"model_id": "b38dae435bb348c9815f95e34087fa24",
"version_major": 2,
"version_minor": 0
},
......@@ -1254,7 +1254,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f17cf5ac8d2b486b8c84aabfb726eb11",
"model_id": "68c3807cce7b42f0859de301b202367e",
"version_major": 2,
"version_minor": 0
},
......@@ -1280,121 +1280,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0e407c23430741488eaa327b35687819",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(IntRangeSlider(value=(0, 24), description='Frame subset:', max=24, style=SliderStyle(descriptio…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"### Subset #2"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"You can give it a custom name that will be used for saving data"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "241a513efae64558bd6cdef928f0def7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Text(value='', description='Subset name:', placeholder='optional', style=DescriptionStyle(description_width='i…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Crop a region**"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"You can draw it on the image or select it with the slider (values in pixels).If you do both, only the drawn region will be kept. If you select several regions on the image, they will be divided into several subsets"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"Draw using the rectangle shape, hit ENTER while you're done.If you want more details about the email viewer please visit https://napari.org/"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0517ba9d531949cf9e1dfac03bcdf667",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(LoadedButton(description='Draw ROI', style=ButtonStyle()), HBox(children=(FloatRangeSlider(valu…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Select data based on trajectories duration or frame subset**"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b259aa2b64254cbab95648926474a94d",
"model_id": "da8540f2d9674f01ba27f38da04506d2",
"version_major": 2,
"version_minor": 0
},
......@@ -1499,7 +1385,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 17,
"metadata": {
"scrolled": true
},
......@@ -1543,7 +1429,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "abac07026fcd4d53bcac236ec813d728",
"model_id": "fc2264143f174fd5a2def265a02d713b",
"version_major": 2,
"version_minor": 0
},
......@@ -1628,7 +1514,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 18,
"metadata": {
"scrolled": false
},
......@@ -1703,7 +1589,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"metadata": {},
"outputs": [
{
......@@ -1721,7 +1607,7 @@
{
"data": {
"text/markdown": [
"You set 2 subsets. Edit their names and order to be plotted if needed."
"You set 1 subsets. Edit their names and order to be plotted if needed."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
......@@ -1734,34 +1620,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{'xlim': (36.61438636861541, 472.0845405438229), 'ylim': (38.13919994626437, 473.7006114895953), 'zlim': (21.689340569848213, 473.7984788052534), 'min_traj_len': 5, 'max_traj_len': 25, 'frame_subset': (0, 6), 'track_list': None, 'track_ROI': None, 'name': ''}\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "407518c947eb48328d735243c2f0aef4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Text(value='', description='Subset name:', placeholder='optional', style=DescriptionStyle(descr…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'xlim': (36.61438636861541, 472.0845405438229), 'ylim': (38.13919994626437, 473.7006114895953), 'zlim': (21.689340569848213, 473.7984788052534), 'min_traj_len': 4, 'max_traj_len': 25, 'frame_subset': (18, 24), 'track_list': None, 'track_ROI': None, 'name': ''}\n"
"{'xlim': (36.61438636861541, 472.0845405438229), 'ylim': (38.13919994626437, 473.7006114895953), 'zlim': (21.689340569848213, 473.7984788052534), 'min_traj_len': 0, 'max_traj_len': 25, 'frame_subset': (0, 24), 'track_list': None, 'track_ROI': None, 'name': ''}\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c8fa63be43e44574bc00854c8d62be7f",
"model_id": "97d3fc23616f48b5811cf2515e121244",
"version_major": 2,
"version_minor": 0
},
......@@ -1841,7 +1706,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"metadata": {
"scrolled": true
},
......@@ -1885,7 +1750,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 21,
"metadata": {
"scrolled": false
},
......@@ -1917,7 +1782,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "eadd9d5efd9640358d05f2740562123b",
"model_id": "13a3675d7e5a4423bcb801c988e8e72c",
"version_major": 2,
"version_minor": 0
},
......@@ -1943,7 +1808,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "814a76f76b0c4ab5932739cf8f30249b",
"model_id": "65323ef7dc7e4cf682fbaa9468b91546",
"version_major": 2,
"version_minor": 0
},
......@@ -1993,7 +1858,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6e7af2cda51442afaa4346a57886d38a",
"model_id": "25eb164ffb204fa48e2eb9a9b1ab69d9",
"version_major": 2,
"version_minor": 0
},
......@@ -2019,7 +1884,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7c9129d2a2334867a857ca34159e2d80",
"model_id": "1549f64ed8db40a8b08fadaacbdc4e04",
"version_major": 2,
"version_minor": 0
},
......@@ -2045,7 +1910,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1941992b940c416ab38023a0ecd8c984",
"model_id": "981696b2745d406b8ca9f700c33eae21",
"version_major": 2,
"version_minor": 0
},
......@@ -2071,7 +1936,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d24ebdde44cd4231bef40bfde40c2889",
"model_id": "bd138f531e17472ab6433980c1caaf58",
"version_major": 2,
"version_minor": 0
},
......@@ -2121,7 +1986,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "034f26938f3f4ae08b3a64329f01628e",
"model_id": "a4f7e6ff0ed149c8ac51b74b0a80f44c",
"version_major": 2,
"version_minor": 0
},
......@@ -2135,7 +2000,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "09b3ff0990df4d23b8dc5cd3593f1d32",
"model_id": "8c744a40a6f04c13854349444e10a5ec",
"version_major": 2,
"version_minor": 0
},
......@@ -2149,7 +2014,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "213613cdf4e3458489f40bc65fbf1276",
"model_id": "5667d83b2d91479bb29d737f0b2b980c",
"version_major": 2,
"version_minor": 0
},
......@@ -2199,7 +2064,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e15118a22d7f424b8f123cbc076aed6a",
"model_id": "6f327435e2d24f04996f3c66fe8abed6",
"version_major": 2,
"version_minor": 0
},
......@@ -2225,7 +2090,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "65a9004bd81442ff8099832f2e15e2c8",
"model_id": "1257173785234fe3910e4a64c3ae06cd",
"version_major": 2,
"version_minor": 0
},
......@@ -2251,7 +2116,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "14304c8ded684d38805cb38f1b5e7859",
"model_id": "c63a328e835049d9a0669d7dc16e8796",
"version_major": 2,
"version_minor": 0
},
......@@ -2277,7 +2142,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c9cdb2e651bf49a7987162e16888c2cf",
"model_id": "9dc753454d9649fe82c126b4c2c22216",
"version_major": 2,
"version_minor": 0
},
......@@ -2291,7 +2156,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3a7040ab7b7746669e21c0cb3f52ac68",
"model_id": "213376498f4b4ea5882de69b59601a6d",
"version_major": 2,
"version_minor": 0
},
......@@ -2305,7 +2170,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8b4cc4efd16f4fb884d6bc6aa7a750f5",
"model_id": "c8a860e422b64ff8a88f7d84dd5c5c1c",
"version_major": 2,
"version_minor": 0
},
......@@ -2331,7 +2196,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cbfe1dc49ee947a0935a5acae0325ec3",
"model_id": "a2c01bb65e434167aad8f0813c2a24ed",
"version_major": 2,
"version_minor": 0
},
......@@ -2539,7 +2404,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 22,
"metadata": {
"scrolled": false
},
......@@ -2559,7 +2424,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "61d1ec020f594138bf04349275a4f93e",
"model_id": "0806a6d660ae4b8a867fee511a416f29",
"version_major": 2,
"version_minor": 0
},
......@@ -2709,7 +2574,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 23,
"metadata": {
"scrolled": false
},
......@@ -2842,7 +2707,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"metadata": {
"scrolled": false
},
......@@ -2863,23 +2728,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Analyzing subset #1, named: 11\n",
"Analyzing subset #1, named: 15\n",
"Computing means along trajectories...\n",
"Plotting trajectories...\n",
"Plotting total trajectories\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"MSD analysis...\n"
"Plotting total trajectories\n",
"MSD analysis...\n",
"Voronoi analysis...\n",
"Plotting instantaneous parameters histograms...\n",
"Plotting whole-track parameters histograms...\n",
"Plotting scatter plots of instantaneous parameters...\n",
"Plotting scatter plots of whole-track parameters...\n",
"Plotting instantaneous parameters boxplots...\n",
"Plotting whole-track boxplots...\n"
]
}
],
......
%% Cell type:code id: tags:
``` python
import os
import os.path as osp
import pickle
import napari
from skimage import io
from skimage.color import rgb2gray
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
import seaborn as sns
import pandas as pd
import warnings
import ipywidgets as widgets
from ipywidgets import HBox, VBox, interact, interact_manual, TwoByTwoLayout, GridspecLayout, Label, AppLayout
from ipyfilechooser import FileChooser
from IPython.display import HTML, Markdown, display, clear_output
from traitlets import traitlets
from track_analyzer import prepare as tpr
from track_analyzer import plotting as tpl
from track_analyzer import calculate as tca
from track_analyzer.scripts.analyze_tracks import traj_analysis
from track_analyzer.scripts.analyze_maps import map_analysis
from track_analyzer.scripts.compare_datasets import compare_datasets
from napari.settings import get_settings
get_settings().application.ipy_interactive = False # disable interactive usage of Napari viewer (necessary for tpr.get_coordinates)
warnings.filterwarnings('ignore')
%matplotlib inline
def printmd(string):
display(Markdown(string))
cwd = os.getcwd() # working directory
plot_param = tpl.make_plot_config() # some config parameters
color_list = plot_param['color_list'] # a list of colors often used
# Hide code
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
```
%%%% Output: stream
_ _ _
| |_ _ __ __ _ ___| | __ __ _ _ __ __ _| |_ _ _______ _ __
| __| '__/ _` |/ __| |/ / / _` | '_ \ / _` | | | | |_ / _ \ '__|
| |_| | | (_| | (__| < | (_| | | | | (_| | | |_| |/ / __/ |
\__|_| \__,_|\___|_|\_\ \__,_|_| |_|\__,_|_|\__, /___\___|_|
|___/
Track Analyzer - Quantification and visualization of tracking data.
Developed and maintained by Arthur Michaut: arthur.michaut@gmail.com
%%%% Output: execute_result
<IPython.core.display.HTML object>
%% Cell type:markdown id: tags:
# Preparation module
## Loading data
%% Cell type:code id: tags:
``` python
#choose positions file
fc_table = FileChooser(cwd)
fc_table.use_dir_icons = True
fc_table.title = '<b>Tracking data file</b>'
sep_wid = widgets.Dropdown(options=[',',';', 'tab', ' '],value=',',description='column separator:',style={'description_width': 'initial'})
header_wid = widgets.Dropdown(options=['yes','no'],value='yes',description='first row = column names?',style={'description_width': 'initial'})
printmd("""**Browse your file system to the table of tracked data (only .txt and .csv are supported)**""")
display(fc_table,sep_wid,header_wid)
```
%%%% Output: display_data
**Browse your file system to the table of tracked data (only .txt and .csv are supported)**
%%%% Output: display_data
%%%% Output: display_data
%%%% Output: display_data
%% Cell type:code id: tags:
``` python
# get position file path
data_dir = fc_table.selected_path
data_file = fc_table.selected
if data_file is None:
raise Exception("**ERROR: no data table has been selected**")
# choose image file
printmd("""**(Optional) Browse your file system to the image file**
You can plot your data on your image. The image can be a single image or a stack (a 2D time series or a 3D time series).
Only tif images are supported. """)
fc_im = FileChooser(data_dir)
fc_im.use_dir_icons = True
fc_im.title = '<b>Image file</b>'
display(fc_im)
```
%%%% Output: display_data
**(Optional) Browse your file system to the image file**
You can plot your data on your image. The image can be a single image or a stack (a 2D time series or a 3D time series).
Only tif images are supported.
%%%% Output: display_data
%% Cell type:code id: tags:
``` python
# get image file path
im_file = fc_im.selected
#im_file = "/Users/amichaut/Desktop/Fluo-N3DH-CE/stack.tif"
# analyze image
y_size,x_size = [512,512] #default size of an image to inialize the make info widget
image = tpr.get_image(data_dir,filename=im_file,verbose=True)
if image['image_size'] is not None:
y_size,x_size = image['image_size']
get_image_size = False
else:
get_image_size = True # to call get_image again after info.txt is generated
# swap z and t dimensions if needed
check_swap_wid = False # bool to retrieve swap_wid value if necessary
if image['t_dim'] is not None and image['z_dim'] is not None:
check_swap_wid=True
printmd("If there is an error between t and z dimension, you can swap these dimensions")
swap_wid = widgets.ToggleButton(value=False,description='Swap z and t')
display(swap_wid)
# refresh database and info if needed
database_fn=osp.join(data_dir,'data_base.p')
info_fn=osp.join(data_dir,'info.txt')
printmd("---")
if osp.exists(database_fn):
printmd('The database already exists, do you want to refresh it?')
refresh_db_wid=widgets.ToggleButton(value=False,description='Refresh database')
display(refresh_db_wid)
if osp.exists(info_fn):
printmd("The info.txt file already exists, do you want to refresh it?")
refresh_info_wid=widgets.ToggleButton(value=False,description='Refresh info')
display(refresh_info_wid)
```
%%%% Output: display_data
---
%%%% Output: display_data
The database already exists, do you want to refresh it?
%%%% Output: display_data
%%%% Output: display_data
The info.txt file already exists, do you want to refresh it?
%%%% Output: display_data
%% Cell type:code id: tags:
``` python
printmd("**Don't forget to run this cell!**") # no output cell, make it visible
#swap z and t
if check_swap_wid:
if swap_wid.value:
t_dim = image['t_dim']
z_dim = image['z_dim']
image['t_dim'] = z_dim
image['z_dim'] = t_dim
printmd("**z and t swapped!**")
im = io.imread(image['image_fn'])
printmd("4D image with {} time steps and {} z slices".format(im.shape[image['t_dim']],im.shape[image['z_dim']]))
del im # free memory
# retrieve refresh widgets values
refresh_db=refresh_db_wid.value if osp.exists(database_fn) else True
refresh_info=refresh_info_wid.value if osp.exists(info_fn) else True
# get info
if refresh_info:
length_unit_wid=widgets.Dropdown(options=['um', 'mm', 'au'],value='um',description='Length unit:',style={'description_width': 'initial'})
time_unit_wid=widgets.Dropdown(options=['min', 's', 'hr', 'au'],value='min',description='Time unit:',style={'description_width': 'initial'})
length_sc_wid=widgets.BoundedFloatText(value=1.0,min=0,max=1e4,description='Pixel size:',style={'description_width': 'initial'})
z_sc_wid=widgets.BoundedFloatText(value=0,min=0,max=1e4,description='z step:',style={'description_width': 'initial'})
time_sc_wid=widgets.BoundedFloatText(value=1.0,min=0,max=1e4,description='Frame interval:',style={'description_width': 'initial'})
width_wid=widgets.BoundedIntText(value=x_size,min=0,max=1e4,description='Image width (px):',style={'description_width': 'initial'})
height_wid=widgets.BoundedIntText(value=y_size,min=0,max=1e4,description='Image height (px):',style={'description_width': 'initial'})
left_box = VBox([length_unit_wid, time_unit_wid,width_wid])
right_box = VBox([length_sc_wid, time_sc_wid,height_wid])
box = HBox([left_box, right_box])
printmd("**Information about the data**")
display(box)
printmd("In the data table, are the positions given in pixels or in the length unit (given above)?")
table_unit_wid=widgets.Dropdown(options=['px', 'unit'],value='px',description='Data unit:',style={'description_width': 'initial'})
display(table_unit_wid)
printmd("If the lengthscale in z is different from the xy lengthscale, enter the z step (in length unit). If not, leave it to zero.")
display(z_sc_wid)
wid_list = [length_unit_wid,time_unit_wid,length_sc_wid,time_sc_wid,width_wid,height_wid,table_unit_wid,z_sc_wid]
param_names = ['length_unit','time_unit','lengthscale','timescale','image_width','image_height','table_unit','z_step']
```
%%%% Output: display_data
**Don't forget to run this cell!**
%% Cell type:code id: tags:
``` python
printmd("**Don't forget to run this cell!**") # no output cell, make it visible
# save info as txt file
if refresh_info:
info = {}
with open(info_fn,'w+') as f:
for couple in zip(param_names,wid_list):
info[couple[0]]=couple[1].value
f.write('{}:{}\n'.format(couple[0],couple[1].value))
else:
info = tpr.get_info(data_dir)
image = tpr.get_image(data_dir,filename=im_file,verbose=True)
```
%%%% Output: display_data
**Don't forget to run this cell!**
%% Cell type:code id: tags:
``` python
printmd("**Don't forget to run this cell!**") # no output cell, make it visible