Skip to content

Commit

Permalink
update classify_mitosis_data_prep.ipynb: fix test column mitosis_type…
Browse files Browse the repository at this point in the history
… missing issue
  • Loading branch information
dummyindex committed Nov 1, 2023
1 parent 55e4897 commit 4986c21
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions notebooks/classify_mitosis_data_prep.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,17 @@
" test_class2sample_extra_info[key] = np.array(all_class2sample_extra_info[key], dtype=object)[_test_indices]\n",
" train_class2sample_extra_info[key] = list(train_class2sample_extra_info[key])\n",
" test_class2sample_extra_info[key] = list(test_class2sample_extra_info[key])\n",
"\n",
"\n",
"# # for debug\n",
"if DEBUG:\n",
" test_sample_num = 3\n",
" padding_pixels = [1, 20]\n",
" train_class2samples = {key: value[:test_sample_num] for key, value in all_class2samples.items()}\n",
" test_class2samples = {key: value[:test_sample_num] for key, value in all_class2samples.items()}\n",
" train_class2sample_extra_info = {key: value[:test_sample_num] for key, value in all_class2sample_extra_info.items()}\n",
" test_class2sample_extra_info = {key: value[:test_sample_num] for key, value in all_class2sample_extra_info.items()}\n",
"\n",
"\n"
]
},
Expand Down Expand Up @@ -473,7 +484,7 @@
"metadata": {},
"outputs": [],
"source": [
"video_frames_and_masks_from_sample(train_class2samples[\"normal\"][6])[0][0].shape\n",
"video_frames_and_masks_from_sample(train_class2samples[\"normal\"][0])[0][0].shape\n",
"# train_class2samples[\"normal\"][6][1].show_panel()"
]
},
Expand All @@ -488,13 +499,20 @@
"importlib.reload(livecellx.track.classify_utils)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check some sample generation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"idx_to_check = 6\n",
"idx_to_check = 0\n",
"video_frames, video_frame_masks = video_frames_and_masks_from_sample(train_class2samples[\"normal\"][idx_to_check], padding_pixels=0)\n",
"print(\"video frames dtype:\", video_frames[0].dtype)\n",
"print(\"video frames shape:\", video_frames[0].shape)\n",
Expand Down Expand Up @@ -612,20 +630,32 @@
"Include original, drop-div and st"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"train_class2sample_extra_info"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import copy\n",
"from copy import deepcopy\n",
"\n",
"def modify_class2sample_extra_info(class2sample_extra_info: Dict[str, List[Dict]], mitosis_traj_type, copy_info=True):\n",
"def modify_class2sample_extra_info(class2sample_extra_info: Dict[str, List[Dict]], mitosis_traj_type, copy=True):\n",
" for cls in class2sample_extra_info:\n",
" for _info in class2sample_extra_info[cls]:\n",
" if copy_info:\n",
" _info = copy_info.deepcopy(_info)\n",
" for i, _info in enumerate(class2sample_extra_info[cls]):\n",
" if copy:\n",
" _info = dict(_info)\n",
" _info[\"mitosis_traj_type\"] = mitosis_traj_type\n",
" class2sample_extra_info[cls][i] = _info\n",
" \n",
"\n",
"modify_class2sample_extra_info(train_class2sample_extra_info, \"full\")\n",
"modify_class2sample_extra_info(test_class2sample_extra_info, \"full\")\n",
Expand Down Expand Up @@ -712,15 +742,6 @@
"import livecellx.core.sc_video_utils\n",
"importlib.reload(livecellx.core.sc_video_utils)\n",
"\n",
"# # for debug\n",
"if DEBUG:\n",
" test_sample_num = 3\n",
" padding_pixels = [1, 20]\n",
" train_class2samples = {key: value[:test_sample_num] for key, value in all_class2samples.items()}\n",
" test_class2samples = {key: value[:test_sample_num] for key, value in all_class2samples.items()}\n",
" train_class2sample_extra_info = {key: value[:test_sample_num] for key, value in all_class2sample_extra_info.items()}\n",
" test_class2sample_extra_info = {key: value[:test_sample_num] for key, value in all_class2sample_extra_info.items()}\n",
"\n",
"# padding_pixels = [20]\n",
"\n",
"train_sample_info_df = livecellx.core.sc_video_utils.gen_class2sample_samples(\n",
Expand Down

0 comments on commit 4986c21

Please sign in to comment.