Skip to content

Commit

Permalink
feat: add patch extractor factory demo
Browse files Browse the repository at this point in the history
  • Loading branch information
melisande-c committed Jan 28, 2025
1 parent 509aba6 commit 24a0013
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 105 deletions.
90 changes: 90 additions & 0 deletions src/careamics/dataset_ng/patch_extractor_factory_demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from careamics.config import create_n2n_configuration\n",
"from careamics.dataset_ng.patch_extractor.patch_extractor_factory import (\n",
" create_patch_extractors,\n",
")\n",
"\n",
"rng = np.random.default_rng()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# define example data\n",
"array1 = np.arange(36).reshape(1, 6, 6)\n",
"array2 = np.arange(50).reshape(2, 5, 5)\n",
"target1 = rng.integers(0, 1, size=array1.shape, endpoint=True)\n",
"target2 = rng.integers(0, 1, size=array2.shape, endpoint=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"config = create_n2n_configuration(\n",
" \"test_exp\",\n",
" data_type=\"array\",\n",
" axes=\"SYX\",\n",
" patch_size=(8, 8),\n",
" batch_size=1,\n",
" num_epochs=1,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"train_inputs, train_targets, _, _ = create_patch_extractors(\n",
" config.data_config, [array1, array2], [target1, target2]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"train_inputs.extract_patch(data_idx=0, sample_idx=0, coords=(2, 2), patch_size=(3,3))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.10.16"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
105 changes: 0 additions & 105 deletions src/careamics/dataset_ng/patch_extractor_factory_dev.ipynb

This file was deleted.

0 comments on commit 24a0013

Please sign in to comment.