Skip to content

Commit

Permalink
Deploying to gh-pages from main @ 6edfb3c 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
mogres committed Feb 5, 2024
1 parent 3f11faa commit 613d60e
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 60 deletions.
21 changes: 19 additions & 2 deletions _modules/cellpack/autopack/Analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,7 @@ <h1>Source code for cellpack.autopack.Analysis</h1><div class="highlight"><pre>
<span class="n">image_export_options</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">show_grid</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">plot_figures</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">save_gradient_data_as_image</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Packs one seed of a recipe and returns the recipe object</span>
Expand Down Expand Up @@ -2560,13 +2561,26 @@ <h1>Source code for cellpack.autopack.Analysis</h1><div class="highlight"><pre>
<span class="n">plt</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> <span class="c1"># closes the current figure</span>

<span class="k">if</span> <span class="n">image_export_options</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">image_writer</span> <span class="o">=</span> <span class="n">ImageWriter</span><span class="p">(</span>
<span class="n">env_image_writer</span> <span class="o">=</span> <span class="n">ImageWriter</span><span class="p">(</span>
<span class="n">env</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="n">seed_basename</span><span class="p">,</span>
<span class="n">output_path</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">figures_path</span><span class="p">,</span>
<span class="o">**</span><span class="n">image_export_options</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">image_writer</span><span class="o">.</span><span class="n">export_image</span><span class="p">()</span>
<span class="n">env_image_writer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">create_voxelization</span><span class="p">(</span><span class="n">env_image_writer</span><span class="p">)</span>
<span class="n">env_image_writer</span><span class="o">.</span><span class="n">export_image</span><span class="p">()</span>

<span class="k">if</span> <span class="n">save_gradient_data_as_image</span><span class="p">:</span>
<span class="n">gradient_data_figure_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">figures_path</span> <span class="o">/</span> <span class="s2">&quot;gradient_data_figures&quot;</span>
<span class="n">gradient_data_figure_path</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">gradient</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">gradients</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">grid_image_writer</span> <span class="o">=</span> <span class="n">ImageWriter</span><span class="p">(</span>
<span class="n">env</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">seed_basename</span><span class="si">}</span><span class="s2">_grid_data&quot;</span><span class="p">,</span>
<span class="n">output_path</span><span class="o">=</span><span class="n">gradient_data_figure_path</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">grid_image_writer</span> <span class="o">=</span> <span class="n">gradient</span><span class="o">.</span><span class="n">create_voxelization</span><span class="p">(</span><span class="n">grid_image_writer</span><span class="p">)</span>
<span class="n">grid_image_writer</span><span class="o">.</span><span class="n">export_image</span><span class="p">()</span>

<span class="k">return</span> <span class="p">(</span>
<span class="n">center_distance_dict</span><span class="p">,</span>
Expand All @@ -2592,6 +2606,7 @@ <h1>Source code for cellpack.autopack.Analysis</h1><div class="highlight"><pre>
<span class="n">recipe_version</span><span class="o">=</span><span class="s2">&quot;1.0.0&quot;</span><span class="p">,</span>
<span class="n">image_export_options</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">parallel</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">save_gradient_data_as_image</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Runs multiple packings of the same recipe in a loop. This workflow</span>
Expand Down Expand Up @@ -2691,6 +2706,7 @@ <h1>Source code for cellpack.autopack.Analysis</h1><div class="highlight"><pre>
<span class="n">ingredient_key_dict</span><span class="o">=</span><span class="n">ingredient_key_dict</span><span class="p">,</span>
<span class="n">get_distance_distribution</span><span class="o">=</span><span class="n">get_distance_distribution</span><span class="p">,</span>
<span class="n">image_export_options</span><span class="o">=</span><span class="n">image_export_options</span><span class="p">,</span>
<span class="n">save_gradient_data_as_image</span><span class="o">=</span><span class="n">save_gradient_data_as_image</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">future</span> <span class="ow">in</span> <span class="n">concurrent</span><span class="o">.</span><span class="n">futures</span><span class="o">.</span><span class="n">as_completed</span><span class="p">(</span><span class="n">futures</span><span class="p">):</span>
Expand Down Expand Up @@ -2732,6 +2748,7 @@ <h1>Source code for cellpack.autopack.Analysis</h1><div class="highlight"><pre>
<span class="n">image_export_options</span><span class="o">=</span><span class="n">image_export_options</span><span class="p">,</span>
<span class="n">show_grid</span><span class="o">=</span><span class="n">show_grid</span><span class="p">,</span>
<span class="n">plot_figures</span><span class="o">=</span><span class="n">plot_figures</span><span class="p">,</span>
<span class="n">save_gradient_data_as_image</span><span class="o">=</span><span class="n">save_gradient_data_as_image</span><span class="p">,</span>
<span class="p">)</span>

<span class="bp">self</span><span class="o">.</span><span class="n">writeJSON</span><span class="p">(</span><span class="n">center_distance_file</span><span class="p">,</span> <span class="n">center_distance_dict</span><span class="p">)</span>
Expand Down
35 changes: 16 additions & 19 deletions _modules/cellpack/autopack/Environment.html
Original file line number Diff line number Diff line change
Expand Up @@ -3482,53 +3482,50 @@ <h1>Source code for cellpack.autopack.Environment</h1><div class="highlight"><pr

<div class="viewcode-block" id="Environment.create_voxelization">
<a class="viewcode-back" href="../../../cellpack.autopack.html#cellpack.autopack.Environment.Environment.create_voxelization">[docs]</a>
<span class="k">def</span> <span class="nf">create_voxelization</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">image_data</span><span class="p">,</span> <span class="n">image_size</span><span class="p">,</span> <span class="n">voxel_size</span><span class="p">,</span> <span class="n">hollow</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">create_voxelization</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">image_writer</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Update the image data for all molecules in the recipe by creating voxelized</span>
<span class="sd"> representations.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> image_data: numpy.ndarray</span>
<span class="sd"> The image data to update.</span>
<span class="sd"> image_size: list</span>
<span class="sd"> The size of the image data.</span>
<span class="sd"> voxel_size: float</span>
<span class="sd"> The size of a voxel in the image data.</span>
<span class="sd"> hollow: bool</span>
<span class="sd"> If True, the voxelization will be hollow.</span>
<span class="sd"> image_writer: ImageWriter</span>
<span class="sd"> The image writer to use for writing the voxelized representations.</span>

<span class="sd"> Returns</span>
<span class="sd"> ----------</span>
<span class="sd"> image_data: numpy.ndarray</span>
<span class="sd"> The updated image data.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">channel_colors</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">channel_colors</span> <span class="o">=</span> <span class="p">{}</span>

<span class="k">for</span> <span class="n">obj</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">packed_objects</span><span class="o">.</span><span class="n">get_all</span><span class="p">():</span>
<span class="n">mesh_store</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="n">obj</span><span class="o">.</span><span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">image_data</span><span class="p">:</span>
<span class="n">image_data</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">image_size</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">numpy</span><span class="o">.</span><span class="n">uint8</span><span class="p">)</span>
<span class="k">if</span> <span class="n">obj</span><span class="o">.</span><span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">image_writer</span><span class="o">.</span><span class="n">image_data</span><span class="p">:</span>
<span class="n">image_writer</span><span class="o">.</span><span class="n">image_data</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span>
<span class="n">image_writer</span><span class="o">.</span><span class="n">image_size</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">numpy</span><span class="o">.</span><span class="n">uint8</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">obj</span><span class="o">.</span><span class="n">color</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">color</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">color</span>
<span class="k">if</span> <span class="nb">all</span><span class="p">([</span><span class="n">x</span> <span class="o">&lt;=</span> <span class="mi">1</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">obj</span><span class="o">.</span><span class="n">color</span><span class="p">]):</span>
<span class="n">color</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">col</span> <span class="o">*</span> <span class="mi">255</span><span class="p">)</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">obj</span><span class="o">.</span><span class="n">color</span><span class="p">]</span>
<span class="n">channel_colors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">color</span><span class="p">)</span>
<span class="n">channel_colors</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">color</span>
<span class="k">if</span> <span class="n">obj</span><span class="o">.</span><span class="n">is_compartment</span><span class="p">:</span>
<span class="n">mesh_store</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mesh_store</span>

<span class="n">image_data</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">ingredient</span><span class="o">.</span><span class="n">create_voxelization</span><span class="p">(</span>
<span class="n">image_data</span><span class="o">=</span><span class="n">image_data</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">name</span><span class="p">],</span>
<span class="n">image_writer</span><span class="o">.</span><span class="n">image_data</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">ingredient</span><span class="o">.</span><span class="n">create_voxelization</span><span class="p">(</span>
<span class="n">image_data</span><span class="o">=</span><span class="n">image_writer</span><span class="o">.</span><span class="n">image_data</span><span class="p">[</span><span class="n">obj</span><span class="o">.</span><span class="n">name</span><span class="p">],</span>
<span class="n">bounding_box</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">boundingBox</span><span class="p">,</span>
<span class="n">voxel_size</span><span class="o">=</span><span class="n">voxel_size</span><span class="p">,</span>
<span class="n">image_size</span><span class="o">=</span><span class="n">image_size</span><span class="p">,</span>
<span class="n">voxel_size</span><span class="o">=</span><span class="n">image_writer</span><span class="o">.</span><span class="n">voxel_size</span><span class="p">,</span>
<span class="n">image_size</span><span class="o">=</span><span class="n">image_writer</span><span class="o">.</span><span class="n">image_size</span><span class="p">,</span>
<span class="n">position</span><span class="o">=</span><span class="n">obj</span><span class="o">.</span><span class="n">position</span><span class="p">,</span>
<span class="n">rotation</span><span class="o">=</span><span class="n">obj</span><span class="o">.</span><span class="n">rotation</span><span class="p">,</span>
<span class="n">hollow</span><span class="o">=</span><span class="n">hollow</span><span class="p">,</span>
<span class="n">hollow</span><span class="o">=</span><span class="n">image_writer</span><span class="o">.</span><span class="n">hollow</span><span class="p">,</span>
<span class="n">mesh_store</span><span class="o">=</span><span class="n">mesh_store</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">image_writer</span><span class="o">.</span><span class="n">channel_colors</span> <span class="o">=</span> <span class="n">channel_colors</span>

<span class="k">return</span> <span class="n">image_data</span><span class="p">,</span> <span class="n">channel_colors</span></div>
<span class="k">return</span> <span class="n">image_writer</span></div>
</div>

</pre></div>
Expand Down
Loading

0 comments on commit 613d60e

Please sign in to comment.