Skip to content

Commit

Permalink
Updated simulation codes
Browse files Browse the repository at this point in the history
  • Loading branch information
zengjiexia committed Jul 16, 2023
1 parent 5467fff commit 3dd5941
Show file tree
Hide file tree
Showing 4 changed files with 460 additions and 274 deletions.
File renamed without changes.
149 changes: 149 additions & 0 deletions simulation/ACT_SR_simulation_final.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "a0bc1bd5",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"from PIL import Image, ImageDraw\n",
"from scipy import ndimage\n",
"import tifffile as tiff\n",
"import matplotlib.pyplot as plt\n",
"from tqdm import tqdm\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "6e0364c6",
"metadata": {},
"outputs": [],
"source": [
"import toolbox"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e300fdbf",
"metadata": {},
"outputs": [],
"source": [
"obj = toolbox.SR_image(4096, 8, 12.65)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e1ed57e0-2313-465e-8568-68e52675aac5",
"metadata": {},
"outputs": [],
"source": [
"data_path = r\"D:\\Work\\ACT_simulation\\Simulated_imgs_straight_2\"\n",
"filenames = [\"X0Y0R0W0\",\"X0Y0R0W1\",\"X0Y0R0W2\",\"X0Y0R1W0\",\"X0Y0R1W1\",\"X0Y0R1W2\",\"X0Y0R2W0\",\"X0Y0R2W1\",\"X0Y0R2W2\" ]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1c907763-61fb-4a95-a2a4-d8120ffe6013",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|████████████████████████████████████████████████████████████████████████████████████| 9/9 [11:04<00:00, 73.87s/it]\n"
]
}
],
"source": [
"obj.set_particle_details(shape='straight', number=50, size='auto')\n",
"obj.set_intensity(mean=4000, sigma=0.2)\n",
"obj.set_noise(mean=1000, sigma=0.2)\n",
"obj.set_frame(number_of_frame=500)\n",
"obj.set_drift(apply_drift=1, max_drift_per_frame=3)\n",
"obj.generate_particle_list()\n",
"for i in tqdm(filenames):\n",
" obj.generate_particle_positions()\n",
" obj.set_path_name(data_path, i)\n",
" obj.draw_groundtruth()\n",
" obj.generate_blinks()\n",
" obj.generate_base_image()\n",
" obj.add_fiducials(number_of_fiducial=3, fiducial_brightness_rate=8)\n",
" obj.create_SR_stack()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "654e8e9e-cef1-48e0-8ace-dc92b7b2fd42",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|████████████████████████████████████████████████████████████████████████████████████| 9/9 [11:50<00:00, 78.99s/it]\n"
]
}
],
"source": [
"data_path = r\"D:\\Work\\ACT_simulation\\Simulated_imgs_dot\"\n",
"filenames = [\"X0Y0R0W0\",\"X0Y0R0W1\",\"X0Y0R0W2\",\"X0Y0R1W0\",\"X0Y0R1W1\",\"X0Y0R1W2\",\"X0Y0R2W0\",\"X0Y0R2W1\",\"X0Y0R2W2\" ]\n",
"obj.set_particle_details(shape='dot', number=100, size=100)\n",
"obj.set_intensity(mean=4000, sigma=0.2)\n",
"obj.set_noise(mean=1000, sigma=0.2)\n",
"obj.set_frame(number_of_frame=500)\n",
"obj.set_drift(apply_drift=1, max_drift_per_frame=3)\n",
"obj.generate_particle_list()\n",
"for i in tqdm(filenames):\n",
" obj.generate_particle_positions()\n",
" obj.set_path_name(data_path, i)\n",
" obj.draw_groundtruth()\n",
" obj.generate_blinks()\n",
" obj.generate_base_image()\n",
" obj.add_fiducials(number_of_fiducial=3, fiducial_brightness_rate=8)\n",
" obj.create_SR_stack()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1e8242c5-a71e-4200-adf1-4c73577bed53",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (py3venv)",
"language": "python",
"name": "py3venv"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.16"
},
"toc-autonumbering": true,
"toc-showmarkdowntxt": true
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 3dd5941

Please sign in to comment.