Skip to content

Commit

Permalink
docs(master): Update docs of development line
Browse files Browse the repository at this point in the history
  • Loading branch information
nipreps-bot committed Dec 21, 2024
1 parent 7352520 commit 03d6453
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 20 deletions.
16 changes: 6 additions & 10 deletions master/_modules/niworkflows/anat/ants.html
Original file line number Diff line number Diff line change
Expand Up @@ -1053,15 +1053,11 @@ <h1>Source code for niworkflows.anat.ants</h1><div class="highlight"><pre>
<span class="n">me_7_2</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;ME&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="s1">&#39;5&#39;</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;22_me_7_2&#39;</span><span class="p">)</span>

<span class="c1"># De-pad</span>
<span class="n">depad_mask</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span>
<span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="s1">&#39;-</span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">padding</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;23_depad_mask&#39;</span>
<span class="p">)</span>
<span class="n">depad_segm</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span>
<span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="s1">&#39;-</span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">padding</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;24_depad_segm&#39;</span>
<span class="p">)</span>
<span class="n">depad_gm</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="s1">&#39;-</span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">padding</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;25_depad_gm&#39;</span><span class="p">)</span>
<span class="n">depad_wm</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="s1">&#39;-</span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">padding</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;26_depad_wm&#39;</span><span class="p">)</span>
<span class="n">depad_csf</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="s1">&#39;-</span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">padding</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;27_depad_csf&#39;</span><span class="p">)</span>
<span class="n">depad_mask</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;-</span><span class="si">{</span><span class="n">padding</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;23_depad_mask&#39;</span><span class="p">)</span>
<span class="n">depad_segm</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;-</span><span class="si">{</span><span class="n">padding</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;24_depad_segm&#39;</span><span class="p">)</span>
<span class="n">depad_gm</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;-</span><span class="si">{</span><span class="n">padding</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;25_depad_gm&#39;</span><span class="p">)</span>
<span class="n">depad_wm</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;-</span><span class="si">{</span><span class="n">padding</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;26_depad_wm&#39;</span><span class="p">)</span>
<span class="n">depad_csf</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">ImageMath</span><span class="p">(</span><span class="n">operation</span><span class="o">=</span><span class="s1">&#39;PadImage&#39;</span><span class="p">,</span> <span class="n">op2</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;-</span><span class="si">{</span><span class="n">padding</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;27_depad_csf&#39;</span><span class="p">)</span>

<span class="n">msk_conform</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">niu</span><span class="o">.</span><span class="n">Function</span><span class="p">(</span><span class="n">function</span><span class="o">=</span><span class="n">_conform_mask</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;msk_conform&#39;</span><span class="p">)</span>
<span class="n">merge_tpms</span> <span class="o">=</span> <span class="n">pe</span><span class="o">.</span><span class="n">Node</span><span class="p">(</span><span class="n">niu</span><span class="o">.</span><span class="n">Merge</span><span class="p">(</span><span class="n">in_segmentation_model</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;merge_tpms&#39;</span><span class="p">)</span>
Expand Down Expand Up @@ -1393,7 +1389,7 @@ <h1>Source code for niworkflows.anat.ants</h1><div class="highlight"><pre>
<span class="k">for</span> <span class="n">label</span> <span class="ow">in</span> <span class="n">labels</span><span class="p">:</span>
<span class="n">newnii</span> <span class="o">=</span> <span class="n">nii</span><span class="o">.</span><span class="vm">__class__</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">uint8</span><span class="p">(</span><span class="n">label_data</span> <span class="o">==</span> <span class="n">label</span><span class="p">),</span> <span class="n">nii</span><span class="o">.</span><span class="n">affine</span><span class="p">,</span> <span class="n">nii</span><span class="o">.</span><span class="n">header</span><span class="p">)</span>
<span class="n">newnii</span><span class="o">.</span><span class="n">set_data_dtype</span><span class="p">(</span><span class="s1">&#39;uint8&#39;</span><span class="p">)</span>
<span class="n">out_file</span> <span class="o">=</span> <span class="n">fname_presuffix</span><span class="p">(</span><span class="n">in_segm</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s1">&#39;_class-</span><span class="si">%02d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">label</span><span class="p">,</span> <span class="n">newpath</span><span class="o">=</span><span class="n">cwd</span><span class="p">)</span>
<span class="n">out_file</span> <span class="o">=</span> <span class="n">fname_presuffix</span><span class="p">(</span><span class="n">in_segm</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;_class-</span><span class="si">{</span><span class="n">label</span><span class="si">:</span><span class="s1">02d</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">newpath</span><span class="o">=</span><span class="n">cwd</span><span class="p">)</span>
<span class="n">newnii</span><span class="o">.</span><span class="n">to_filename</span><span class="p">(</span><span class="n">out_file</span><span class="p">)</span>
<span class="n">out_files</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">out_file</span><span class="p">)</span>
<span class="k">return</span> <span class="n">out_files</span>
Expand Down
10 changes: 5 additions & 5 deletions master/_modules/niworkflows/interfaces/itk.html
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ <h1>Source code for niworkflows.interfaces.itk</h1><div class="highlight"><pre>

<span class="n">in_file</span><span class="p">,</span> <span class="n">in_xform</span><span class="p">,</span> <span class="n">ifargs</span><span class="p">,</span> <span class="n">index</span><span class="p">,</span> <span class="n">newpath</span> <span class="o">=</span> <span class="n">args</span>
<span class="n">out_file</span> <span class="o">=</span> <span class="n">fname_presuffix</span><span class="p">(</span>
<span class="n">in_file</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s1">&#39;_xform-</span><span class="si">%05d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">index</span><span class="p">,</span> <span class="n">newpath</span><span class="o">=</span><span class="n">newpath</span><span class="p">,</span> <span class="n">use_ext</span><span class="o">=</span><span class="kc">True</span>
<span class="n">in_file</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;_xform-</span><span class="si">{</span><span class="n">index</span><span class="si">:</span><span class="s1">05d</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">newpath</span><span class="o">=</span><span class="n">newpath</span><span class="p">,</span> <span class="n">use_ext</span><span class="o">=</span><span class="kc">True</span>
<span class="p">)</span>

<span class="n">copy_dtype</span> <span class="o">=</span> <span class="n">ifargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;copy_dtype&#39;</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
Expand Down Expand Up @@ -582,19 +582,19 @@ <h1>Source code for niworkflows.interfaces.itk</h1><div class="highlight"><pre>

<span class="k">if</span> <span class="n">nxforms</span> <span class="o">!=</span> <span class="n">num_files</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span>
<span class="s1">&#39;Number of transforms (</span><span class="si">%d</span><span class="s1">) found in the ITK file does not match&#39;</span>
<span class="s1">&#39; the number of input image files (</span><span class="si">%d</span><span class="s1">).&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">nxforms</span><span class="p">,</span> <span class="n">num_files</span><span class="p">)</span>
<span class="sa">f</span><span class="s1">&#39;Number of transforms (</span><span class="si">{</span><span class="n">nxforms</span><span class="si">}</span><span class="s1">) found in the ITK file does not&#39;</span>
<span class="sa">f</span><span class="s1">&#39; match the number of input image files (</span><span class="si">{</span><span class="n">num_files</span><span class="si">}</span><span class="s1">).&#39;</span>
<span class="p">)</span>

<span class="c1"># At this point splitting transforms will be necessary, generate a base name</span>
<span class="n">out_base</span> <span class="o">=</span> <span class="n">fname_presuffix</span><span class="p">(</span>
<span class="n">tf_file</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s1">&#39;_pos-</span><span class="si">%03d</span><span class="s1">_xfm-</span><span class="si">{:05d}</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">i</span><span class="p">,</span> <span class="n">newpath</span><span class="o">=</span><span class="n">tmp_folder</span><span class="o">.</span><span class="n">name</span>
<span class="n">tf_file</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s1">&#39;_pos-</span><span class="si">{</span><span class="n">i</span><span class="si">:</span><span class="s1">03d</span><span class="si">}</span><span class="s1">_xfm-</span><span class="se">{{</span><span class="s1">:05d</span><span class="se">}}</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">newpath</span><span class="o">=</span><span class="n">tmp_folder</span><span class="o">.</span><span class="n">name</span>
<span class="p">)</span><span class="o">.</span><span class="n">format</span>
<span class="c1"># Split combined ITK transforms file</span>
<span class="n">split_xfms</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">xform_i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nxforms</span><span class="p">):</span>
<span class="c1"># Find start token to extract</span>
<span class="n">startidx</span> <span class="o">=</span> <span class="n">tfdata</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">&#39;#Transform </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">xform_i</span><span class="p">)</span>
<span class="n">startidx</span> <span class="o">=</span> <span class="n">tfdata</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;#Transform </span><span class="si">{</span><span class="n">xform_i</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">next_xform</span> <span class="o">=</span> <span class="n">base_xform</span> <span class="o">+</span> <span class="n">tfdata</span><span class="p">[</span><span class="n">startidx</span> <span class="o">+</span> <span class="mi">1</span> <span class="p">:</span> <span class="n">startidx</span> <span class="o">+</span> <span class="mi">4</span><span class="p">]</span> <span class="o">+</span> <span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">]</span>
<span class="n">xfm_file</span> <span class="o">=</span> <span class="n">out_base</span><span class="p">(</span><span class="n">xform_i</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">xfm_file</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">out_xfm</span><span class="p">:</span>
Expand Down
Loading

0 comments on commit 03d6453

Please sign in to comment.