Skip to content

Commit

Permalink
fix a few typos
Browse files Browse the repository at this point in the history
  • Loading branch information
ismael-mendoza committed May 2, 2024
1 parent 17fb587 commit c6c4065
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions notebooks/01-advanced-deblending.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"from tqdm import tqdm\n",
"from pprint import pprint\n",
"from btk.deblend import DeblendGenerator\n",
"from btk.deblend import PeakLocalMax, SepSingleBand, SepMultiband, Scarlet"
"from btk.deblend import PeakLocalMax, SepSingleBand, Scarlet"
]
},
{
Expand Down Expand Up @@ -108,8 +108,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"All implemented deblenders follow the same template — abstract `Deblender` class. Basically, `Deblender` class standardizes inputs and outputs of the deblender, which allows to simultanously run multiple deblenders on a generated data and benchmark their performance. The `__init__` class has a required argument — `max_n_sources`, which is needed to set a fixed shape for the output of the deblender. All deblenders must implement `__deblend__` method, which performs deblending on the i-th example from the `BlendBatch`. Then we require the output to be packaged into `DeblendExample` data class, which peforms internal validation of the data format -- more on that later. The `__call__` and `batch_call` are internally implemented in the parent class, and user doesn't need to modify them to create a deblender. These two methods implement multiprocessing procedure to efficiently paralelize computation across several CPU cores. Finally `__repr__` class is used for internall bookkeeping. \n",
"\n",
"All implemented deblenders follow the same template — abstract `Deblender` class. Basically, `Deblender` class standardizes inputs and outputs of the deblender, which allows to simultanously run multiple deblenders on a generated data and benchmark their performance. The `__init__` class has a required argument — `max_n_sources`, which is needed to set a fixed shape for the output of the deblender. All deblenders must implement `__deblend__` method, which performs deblending on the i-th example from the `BlendBatch`. Then, we require the output to be packaged into `DeblendExample` data class, which peforms internal validation of the data format -- more on that later. The `__call__` and `batch_call` are internally implemented in the parent class, and user doesn't need to modify them to create a deblender. These two methods implement multiprocessing procedure to efficiently paralelize computation across several CPU cores. Finally `__repr__` class is used for internall bookkeeping. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"class Deblender(ABC):\n",
" \"\"\"Abstract base class containing the measure class for BTK. \"\"\"\n",
Expand Down Expand Up @@ -148,7 +153,7 @@
"class PeakLocalMax(Deblender):\n",
" \"\"\"This class detects centroids with `skimage.feature.peak_local_max`.\"\"\"\n",
"```\n",
"As the comment suggests we will be using a function `skimage.feature.peak_local_max` to perform galaxy detection. By default, this fucniton works on a grayscale image, but in the blend batch we have access to multiple filter. Thus, we will let the user either use a particular filter by specifiyng the index of the band (i.e. `use_band=3`) or average across the filters if `use_mean=True` is turned on. Additionally, we save the parameters such as `sky_level`, `threshold_scale`, and `min_distance` to filter out noisy detections. Here are the details of the `__init__` class:\n",
"As the comment suggests we will be using a function `skimage.feature.peak_local_max` to perform galaxy detection. By default, this function works on a grayscale image, but in the blend batch we have access to multiple filter. Thus, we will let the user either use a particular filter by specifiyng the index of the band (i.e. `use_band=3`) or average across the filters if `use_mean=True` is turned on. Additionally, we include parameters `sky_level`, `threshold_scale`, and `min_distance` to filter out noisy detections. Here are the details of the `__init__` class:\n",
"\n",
"```python\n",
"def __init__(\n",
Expand Down Expand Up @@ -181,7 +186,13 @@
" raise ValueError(\"Only one of the parameters 'use_band' and 'use_mean' has to be set\")\n",
" self.use_mean = use_mean\n",
" self.use_band = use_band\n",
"```\n",
"```\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"Now comes the crucial step —- implementing `deblend` method. The first step of any `deblend` method is to index into the `BlendBatch` and slect the data that corresponds to the i-th example. In this case, we just need the `blend_image`. Once we selected the target grayscale image (either by averaging or by fixing a band) we run `peak_local_max` on the image. Notice that the output coordinates will be in the pixel values, but the requirement for the BTK is to convert output coordinates to `ra` and `dec`, and wrap the detection in `atropy.Table`. Finally we package the output into an object called `DeblendExample` that conevniently stores our data. \n",
"\n",
Expand Down Expand Up @@ -230,7 +241,7 @@
"source": [
"# Deblend Example \n",
"\n",
"BTK supports three kinds of blending realated tasks —— **detection**, **segmentation**, and **deblending** of individual sources. Data for all of these tasks can be stored in the `DeblendingExample`. Specifically, we **require** the user to pass catalog with detections, while **segmentation** and **deblended_images** are optional. This is done because **detetcion** is crucial for doing any other task like (segmentation and deblending), and also we use detections to match the output of the deblender to the ground truth of generated data. \n",
"BTK supports three kinds of blending realated tasks —— **detection**, **segmentation**, and **deblending** of individual sources. Data for all of these tasks can be stored in the `DeblendingExample`. Specifically, we **require** the user to pass catalog with detections, while **segmentation** and **deblended_images** are optional. This is done because **detection** is crucial for doing any other task like (segmentation and deblending), and also we use detections to match the output of the deblender to the ground truth of generated data. \n",
"\n",
"```python\n",
"class DeblendExample:\n",
Expand Down Expand Up @@ -281,7 +292,7 @@
}
],
"source": [
"PLM = PeakLocalMax(max_n_sources, use_mean=True) \n",
"PLM = PeakLocalMax(max_n_sources, use_mean=True)\n",
"deblend_example = PLM.deblend(3, blend_batch) # 3rd example from the batch\n",
"print(deblend_example)\n"
]
Expand Down Expand Up @@ -667,11 +678,6 @@
"\n",
"pprint(results)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit c6c4065

Please sign in to comment.