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 Oct 4, 2024
1 parent 1f28111 commit 7a16732
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 24 deletions.
6 changes: 6 additions & 0 deletions master/_modules/sdcflows/interfaces/bspline.html
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,11 @@ <h1>Source code for sdcflows.interfaces.bspline</h1><div class="highlight"><pre>
<span class="n">mandatory</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">desc</span><span class="o">=</span><span class="s2">&quot;the phase-encoding direction corresponding to in_data&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">jacobian</span> <span class="o">=</span> <span class="n">traits</span><span class="o">.</span><span class="n">Bool</span><span class="p">(</span>
<span class="kc">False</span><span class="p">,</span>
<span class="n">usedefault</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">desc</span><span class="o">=</span><span class="s2">&quot;apply Jacobian determinant correction after unwarping&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">num_threads</span> <span class="o">=</span> <span class="n">traits</span><span class="o">.</span><span class="n">Int</span><span class="p">(</span><span class="n">nohash</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="s2">&quot;number of threads&quot;</span><span class="p">)</span>
<span class="n">approx</span> <span class="o">=</span> <span class="n">traits</span><span class="o">.</span><span class="n">Bool</span><span class="p">(</span>
<span class="kc">True</span><span class="p">,</span>
Expand Down Expand Up @@ -733,6 +738,7 @@ <h1>Source code for sdcflows.interfaces.bspline</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">inputs</span><span class="o">.</span><span class="n">in_data</span><span class="p">,</span>
<span class="bp">self</span><span class="o">.</span><span class="n">inputs</span><span class="o">.</span><span class="n">pe_dir</span><span class="p">,</span>
<span class="bp">self</span><span class="o">.</span><span class="n">inputs</span><span class="o">.</span><span class="n">ro_time</span><span class="p">,</span>
<span class="n">jacobian</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">inputs</span><span class="o">.</span><span class="n">jacobian</span><span class="p">,</span>
<span class="n">xfms</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">inputs</span><span class="o">.</span><span class="n">in_xfms</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">xfm_data2fmap</span><span class="o">=</span><span class="n">data2fmap_xfm</span><span class="p">,</span>
<span class="n">approx</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">inputs</span><span class="o">.</span><span class="n">approx</span><span class="p">,</span>
Expand Down
26 changes: 18 additions & 8 deletions master/_modules/sdcflows/transform.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="n">coordinates</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span>
<span class="n">pe_info</span><span class="p">:</span> <span class="n">Tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">],</span>
<span class="n">hmc_xfm</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span> <span class="o">|</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">jacobian</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span>
<span class="n">fmap_hz</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span>
<span class="n">output_dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">order</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span>
Expand All @@ -402,13 +403,6 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="n">vsm</span> <span class="o">=</span> <span class="n">fmap_hz</span> <span class="o">*</span> <span class="n">pe_info</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">coordinates</span><span class="p">[</span><span class="n">pe_info</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">+=</span> <span class="n">vsm</span>

<span class="c1"># The Jacobian determinant image is the amount of stretching in the PE direction.</span>
<span class="c1"># Using central differences accounts for the shift in neighboring voxels.</span>
<span class="c1"># The full Jacobian at each voxel would be a 3x3 matrix, but because there is</span>
<span class="c1"># only warping in one direction, we end up with a diagonal matrix with two 1s.</span>
<span class="c1"># The following is the other entry at each voxel, and hence the determinant.</span>
<span class="n">jacobian</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">gradient</span><span class="p">(</span><span class="n">vsm</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="n">pe_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>

<span class="n">resampled</span> <span class="o">=</span> <span class="n">ndi</span><span class="o">.</span><span class="n">map_coordinates</span><span class="p">(</span>
<span class="n">data</span><span class="p">,</span>
<span class="n">coordinates</span><span class="p">,</span>
Expand All @@ -417,7 +411,15 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span>
<span class="n">cval</span><span class="o">=</span><span class="n">cval</span><span class="p">,</span>
<span class="n">prefilter</span><span class="o">=</span><span class="n">prefilter</span><span class="p">,</span>
<span class="p">)</span> <span class="o">*</span> <span class="n">jacobian</span>
<span class="p">)</span>

<span class="c1"># The Jacobian determinant image is the amount of stretching in the PE direction.</span>
<span class="c1"># Using central differences accounts for the shift in neighboring voxels.</span>
<span class="c1"># The full Jacobian at each voxel would be a 3x3 matrix, but because there is</span>
<span class="c1"># only warping in one direction, we end up with a diagonal matrix with two 1s.</span>
<span class="c1"># The following is the other entry at each voxel, and hence the determinant.</span>
<span class="k">if</span> <span class="n">jacobian</span><span class="p">:</span>
<span class="n">resampled</span> <span class="o">*=</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">gradient</span><span class="p">(</span><span class="n">vsm</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="n">pe_info</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>

<span class="k">return</span> <span class="n">resampled</span>

Expand Down Expand Up @@ -450,6 +452,7 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="n">fmap_hz</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span>
<span class="n">pe_info</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]],</span>
<span class="n">xfms</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">],</span>
<span class="n">jacobian</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span>
<span class="n">order</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span>
<span class="n">mode</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;constant&quot;</span><span class="p">,</span>
<span class="n">cval</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">,</span>
Expand All @@ -474,6 +477,8 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="sd"> pe_info : :obj:`tuple` of (:obj:`int`, :obj:`float`)</span>
<span class="sd"> A tuple containing the index of the phase-encoding axis in the data array and</span>
<span class="sd"> the readout time (including sign, if displacements must be reversed)</span>
<span class="sd"> jacobian : :class:`bool`</span>
<span class="sd"> If :obj:`True`, apply Jacobian determinant correction after unwarping.</span>
<span class="sd"> xfms : :obj:`list` of obj:`~numpy.ndarray`</span>
<span class="sd"> A list of 4×4 matrices, each one formalizing</span>
<span class="sd"> the estimated head motion alignment to the scan&#39;s reference.</span>
Expand Down Expand Up @@ -512,6 +517,7 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>

<span class="n">func</span> <span class="o">=</span> <span class="n">partial</span><span class="p">(</span>
<span class="n">_sdc_unwarp</span><span class="p">,</span>
<span class="n">jacobian</span><span class="o">=</span><span class="n">jacobian</span><span class="p">,</span>
<span class="n">fmap_hz</span><span class="o">=</span><span class="n">fmap_hz</span><span class="p">,</span>
<span class="n">output_dtype</span><span class="o">=</span><span class="n">output_dtype</span><span class="p">,</span>
<span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span>
Expand Down Expand Up @@ -690,6 +696,7 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="n">pe_dir</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span>
<span class="n">ro_time</span><span class="p">:</span> <span class="nb">float</span> <span class="o">|</span> <span class="n">Sequence</span><span class="p">[</span><span class="nb">float</span><span class="p">],</span>
<span class="n">xfms</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">jacobian</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="n">xfm_data2fmap</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">approx</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="n">order</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span>
Expand All @@ -714,6 +721,8 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="sd"> A valid ``PhaseEncodingDirection`` metadata value.</span>
<span class="sd"> ro_time : :obj:`float` or :obj:`list` of :obj:`float`</span>
<span class="sd"> The total readout time in seconds.</span>
<span class="sd"> jacobian : :class:`bool`</span>
<span class="sd"> If :obj:`True`, apply Jacobian determinant correction after unwarping.</span>
<span class="sd"> xfms : :obj:`None` or :obj:`list`</span>
<span class="sd"> A list of 4×4 matrices, each one formalizing</span>
<span class="sd"> the estimated head motion alignment to the scan&#39;s reference.</span>
Expand Down Expand Up @@ -848,6 +857,7 @@ <h1>Source code for sdcflows.transform</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">mapped</span><span class="o">.</span><span class="n">get_fdata</span><span class="p">(</span><span class="n">dtype</span><span class="o">=</span><span class="s2">&quot;float32&quot;</span><span class="p">),</span> <span class="c1"># fieldmap in Hz</span>
<span class="n">pe_info</span><span class="p">,</span>
<span class="n">xfms</span><span class="p">,</span>
<span class="n">jacobian</span><span class="p">,</span>
<span class="n">output_dtype</span><span class="o">=</span><span class="s1">&#39;float32&#39;</span><span class="p">,</span>
<span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span>
<span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span>
Expand Down
19 changes: 14 additions & 5 deletions master/_modules/sdcflows/workflows/apply/correction.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,14 @@ <h1>Source code for sdcflows.workflows.apply.correction</h1><div class="highligh

<div class="viewcode-block" id="init_unwarp_wf">
<a class="viewcode-back" href="../../../../api/sdcflows.workflows.apply.correction.html#sdcflows.workflows.apply.correction.init_unwarp_wf">[docs]</a>
<span class="k">def</span> <span class="nf">init_unwarp_wf</span><span class="p">(</span><span class="o">*</span><span class="p">,</span> <span class="n">free_mem</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">omp_nthreads</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">debug</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;unwarp_wf&quot;</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">init_unwarp_wf</span><span class="p">(</span>
<span class="o">*</span><span class="p">,</span>
<span class="n">jacobian</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">free_mem</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">omp_nthreads</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">debug</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="s2">&quot;unwarp_wf&quot;</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Set up a workflow that unwarps the input :abbr:`EPI (echo-planar imaging)` dataset.</span>

Expand All @@ -349,11 +356,13 @@ <h1>Source code for sdcflows.workflows.apply.correction</h1><div class="highligh

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> omp_nthreads : :obj:`int`</span>
<span class="sd"> jacobian : :class:`bool`</span>
<span class="sd"> If :obj:`True`, apply Jacobian determinant correction after unwarping.</span>
<span class="sd"> omp_nthreads : :class:`int`</span>
<span class="sd"> Maximum number of threads an individual process may use.</span>
<span class="sd"> name : :obj:`str`</span>
<span class="sd"> name : :class:`str`</span>
<span class="sd"> Unique name of this workflow.</span>
<span class="sd"> debug : :obj:`bool`</span>
<span class="sd"> debug : :class:`bool`</span>
<span class="sd"> Whether to run in *sloppy* mode.</span>

<span class="sd"> Inputs</span>
Expand Down Expand Up @@ -432,7 +441,7 @@ <h1>Source code for sdcflows.workflows.apply.correction</h1><div class="highligh
<span class="n">num_threads</span> <span class="o">=</span> <span class="n">omp_nthreads</span>

<span class="n">resample</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">ApplyCoeffsField</span><span class="p">(</span><span class="n">num_threads</span><span class="o">=</span><span class="n">num_threads</span><span class="p">),</span>
<span class="n">ApplyCoeffsField</span><span class="p">(</span><span class="n">jacobian</span><span class="o">=</span><span class="n">jacobian</span><span class="p">,</span> <span class="n">num_threads</span><span class="o">=</span><span class="n">num_threads</span><span class="p">),</span>
<span class="n">mem_gb</span><span class="o">=</span><span class="n">mem_per_thread</span> <span class="o">*</span> <span class="n">num_threads</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="s2">&quot;resample&quot;</span><span class="p">,</span>
<span class="p">)</span>
Expand Down
2 changes: 1 addition & 1 deletion master/_modules/sdcflows/workflows/fit/pepolar.html
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ <h1>Source code for sdcflows.workflows.fit.pepolar</h1><div class="highlight"><p
<span class="kn">from</span> <span class="nn">sdcflows.interfaces.bspline</span> <span class="kn">import</span> <span class="n">ApplyCoeffsField</span>

<span class="c1"># Separate the runs again, as our ApplyCoeffsField corrects them separately</span>
<span class="n">unwarp</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">ApplyCoeffsField</span><span class="p">(),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;unwarp&quot;</span><span class="p">)</span>
<span class="n">unwarp</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">ApplyCoeffsField</span><span class="p">(</span><span class="n">jacobian</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;unwarp&quot;</span><span class="p">)</span>
<span class="n">unwarp</span><span class="o">.</span><span class="n">interface</span><span class="o">.</span><span class="n">_always_run</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">concat_corrected</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">MergeSeries</span><span class="p">(),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;concat_corrected&quot;</span><span class="p">)</span>

Expand Down
Loading

0 comments on commit 7a16732

Please sign in to comment.