|
74 | 74 | <li class="toctree-l3"><a class="reference internal" href="#cdtools.datasets.Ptycho2DDataset.plot_mean_pattern"><code class="docutils literal notranslate"><span class="pre">Ptycho2DDataset.plot_mean_pattern()</span></code></a></li> |
75 | 75 | <li class="toctree-l3"><a class="reference internal" href="#cdtools.datasets.Ptycho2DDataset.split"><code class="docutils literal notranslate"><span class="pre">Ptycho2DDataset.split()</span></code></a></li> |
76 | 76 | <li class="toctree-l3"><a class="reference internal" href="#cdtools.datasets.Ptycho2DDataset.pad"><code class="docutils literal notranslate"><span class="pre">Ptycho2DDataset.pad()</span></code></a></li> |
| 77 | +<li class="toctree-l3"><a class="reference internal" href="#cdtools.datasets.Ptycho2DDataset.downsample"><code class="docutils literal notranslate"><span class="pre">Ptycho2DDataset.downsample()</span></code></a></li> |
| 78 | +<li class="toctree-l3"><a class="reference internal" href="#cdtools.datasets.Ptycho2DDataset.remove_translations_mask"><code class="docutils literal notranslate"><span class="pre">Ptycho2DDataset.remove_translations_mask()</span></code></a></li> |
| 79 | +<li class="toctree-l3"><a class="reference internal" href="#cdtools.datasets.Ptycho2DDataset.crop_translations"><code class="docutils literal notranslate"><span class="pre">Ptycho2DDataset.crop_translations()</span></code></a></li> |
77 | 80 | </ul> |
78 | 81 | </li> |
79 | 82 | </ul> |
|
472 | 475 | </dl> |
473 | 476 | </dd></dl> |
474 | 477 |
|
| 478 | +<dl class="py method"> |
| 479 | +<dt class="sig sig-object py" id="cdtools.datasets.Ptycho2DDataset.downsample"> |
| 480 | +<span class="sig-name descname"><span class="pre">downsample</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">factor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cdtools.datasets.Ptycho2DDataset.downsample" title="Link to this definition"></a></dt> |
| 481 | +<dd><p>Downsamples all diffraction patterns by the specified factor</p> |
| 482 | +<p>This is an easy way to shrink the amount of data you need to work with |
| 483 | +if the speckle size is much larger than the detector pixel size.</p> |
| 484 | +<p>The downsampling factor must be an integer. The size of the output |
| 485 | +patterns are reduced by the specified factor, with each output pixel |
| 486 | +equal to the sum of a <factor> x <factor> region of pixels in the |
| 487 | +input pattern. This summation is done by pytorch.functional.avg_pool2d.</p> |
| 488 | +<p>Any mask and background data which is stored with the dataset is |
| 489 | +downsampled with the data. The background is downsampled using the same |
| 490 | +method as the data. The mask is expanded so that any output pixel |
| 491 | +containing a masked pixel will be masked.</p> |
| 492 | +<dl class="field-list simple"> |
| 493 | +<dt class="field-odd">Parameters<span class="colon">:</span></dt> |
| 494 | +<dd class="field-odd"><p><strong>factor</strong> (<em>int</em>) – Default 2, the factor to downsample by</p> |
| 495 | +</dd> |
| 496 | +</dl> |
| 497 | +</dd></dl> |
| 498 | + |
| 499 | +<dl class="py method"> |
| 500 | +<dt class="sig sig-object py" id="cdtools.datasets.Ptycho2DDataset.remove_translations_mask"> |
| 501 | +<span class="sig-name descname"><span class="pre">remove_translations_mask</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mask_remove</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cdtools.datasets.Ptycho2DDataset.remove_translations_mask" title="Link to this definition"></a></dt> |
| 502 | +<dd><p>Removes one or more translation positions, and their associated |
| 503 | +properties, from the dataset using logical indexing.</p> |
| 504 | +<p>This takes a 1D mask (boolean torch tensor) with the length |
| 505 | +self.translations.shape[0] (i.e., the number of individual |
| 506 | +translated points). Patterns, translations, and intensities |
| 507 | +associated with indices that are “True” will be removed.</p> |
| 508 | +<section id="parameters"> |
| 509 | +<h2>Parameters:<a class="headerlink" href="#parameters" title="Link to this heading"></a></h2> |
| 510 | +<dl class="simple"> |
| 511 | +<dt>mask_remove<span class="classifier">1D torch.tensor(dtype=torch.bool)</span></dt><dd><p>The boolean mask indicating which elements are to be removed from |
| 512 | +the dataset. True indicates that the corresponding element will be |
| 513 | +removed.</p> |
| 514 | +</dd> |
| 515 | +</dl> |
| 516 | +</section> |
| 517 | +</dd></dl> |
| 518 | + |
| 519 | +<dl class="py method"> |
| 520 | +<dt class="sig sig-object py" id="cdtools.datasets.Ptycho2DDataset.crop_translations"> |
| 521 | +<span class="sig-name descname"><span class="pre">crop_translations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">roi</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cdtools.datasets.Ptycho2DDataset.crop_translations" title="Link to this definition"></a></dt> |
| 522 | +<dd><p>Shrinks the range of translation positions that are analyzed</p> |
| 523 | +<p>This deletes all diffraction patterns associated with x- and |
| 524 | +y-translations that lie outside of a specified rectangular |
| 525 | +region of interest. In essence, this operation crops the “relative |
| 526 | +displacement map” (shown in self.inspect()) down to the region of |
| 527 | +interest.</p> |
| 528 | +<section id="id1"> |
| 529 | +<h2>Parameters:<a class="headerlink" href="#id1" title="Link to this heading"></a></h2> |
| 530 | +<dl class="simple"> |
| 531 | +<dt>roi<span class="classifier">tuple(float, float, float, float)</span></dt><dd><p>The translation-x and -y coordinates that define the rectangular |
| 532 | +region of interest as (in units of meters) |
| 533 | +(left, right, bottom, top). The definition of these bounds are |
| 534 | +based on how an image is normally displayed with matplotlib’s |
| 535 | +imshow. The order in which these elements are defined in roi |
| 536 | +do not matter as long as roi[:2] and roi[2:] correspond with |
| 537 | +the x and y coordinates, respectively.</p> |
| 538 | +</dd> |
| 539 | +</dl> |
| 540 | +</section> |
| 541 | +</dd></dl> |
| 542 | + |
475 | 543 | </dd></dl> |
476 | 544 |
|
477 | 545 | </section> |
|
0 commit comments