Skip to content

Commit 48fa8df

Browse files
Deployed 5fcffeb to dev with MkDocs 1.6.1 and mike 2.1.3
1 parent 0a2a7bd commit 48fa8df

File tree

6 files changed

+353
-832
lines changed

6 files changed

+353
-832
lines changed

dev/objects.inv

-73 Bytes
Binary file not shown.

dev/search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dev/sitemap.xml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,66 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
44
<loc>https://bhklab.github.io/med-imagetools/dev/</loc>
5-
<lastmod>2025-04-14</lastmod>
5+
<lastmod>2025-04-15</lastmod>
66
</url>
77
<url>
88
<loc>https://bhklab.github.io/med-imagetools/dev/database_report/</loc>
9-
<lastmod>2025-04-14</lastmod>
9+
<lastmod>2025-04-15</lastmod>
1010
</url>
1111
<url>
1212
<loc>https://bhklab.github.io/med-imagetools/dev/cli/imgtools/</loc>
13-
<lastmod>2025-04-14</lastmod>
13+
<lastmod>2025-04-15</lastmod>
1414
</url>
1515
<url>
1616
<loc>https://bhklab.github.io/med-imagetools/dev/cli/shell-completion/</loc>
17-
<lastmod>2025-04-14</lastmod>
17+
<lastmod>2025-04-15</lastmod>
1818
</url>
1919
<url>
2020
<loc>https://bhklab.github.io/med-imagetools/dev/reference/dicom-utils/find-dicoms/</loc>
21-
<lastmod>2025-04-14</lastmod>
21+
<lastmod>2025-04-15</lastmod>
2222
</url>
2323
<url>
2424
<loc>https://bhklab.github.io/med-imagetools/dev/reference/dicom-utils/load-dicom/</loc>
25-
<lastmod>2025-04-14</lastmod>
25+
<lastmod>2025-04-15</lastmod>
2626
</url>
2727
<url>
2828
<loc>https://bhklab.github.io/med-imagetools/dev/reference/dicom-utils/lookup_tag/</loc>
29-
<lastmod>2025-04-14</lastmod>
29+
<lastmod>2025-04-15</lastmod>
3030
</url>
3131
<url>
3232
<loc>https://bhklab.github.io/med-imagetools/dev/reference/dicom-utils/similar_tags/</loc>
33-
<lastmod>2025-04-14</lastmod>
33+
<lastmod>2025-04-15</lastmod>
3434
</url>
3535
<url>
3636
<loc>https://bhklab.github.io/med-imagetools/dev/reference/dicom-utils/tag_exists/</loc>
37-
<lastmod>2025-04-14</lastmod>
37+
<lastmod>2025-04-15</lastmod>
3838
</url>
3939
<url>
4040
<loc>https://bhklab.github.io/med-imagetools/dev/reference/dicomsort/dicomsorter/</loc>
41-
<lastmod>2025-04-14</lastmod>
41+
<lastmod>2025-04-15</lastmod>
4242
</url>
4343
<url>
4444
<loc>https://bhklab.github.io/med-imagetools/dev/reference/dicomsort/patternparser/</loc>
45-
<lastmod>2025-04-14</lastmod>
45+
<lastmod>2025-04-15</lastmod>
4646
</url>
4747
<url>
4848
<loc>https://bhklab.github.io/med-imagetools/dev/usage/</loc>
49-
<lastmod>2025-04-14</lastmod>
49+
<lastmod>2025-04-15</lastmod>
5050
</url>
5151
<url>
5252
<loc>https://bhklab.github.io/med-imagetools/dev/usage/CoreTypes/regionbox/</loc>
53-
<lastmod>2025-04-14</lastmod>
53+
<lastmod>2025-04-15</lastmod>
5454
</url>
5555
<url>
5656
<loc>https://bhklab.github.io/med-imagetools/dev/usage/Dicom/interlacer/</loc>
57-
<lastmod>2025-04-14</lastmod>
57+
<lastmod>2025-04-15</lastmod>
5858
</url>
5959
<url>
6060
<loc>https://bhklab.github.io/med-imagetools/dev/usage/Writers/BaseWriter/</loc>
61-
<lastmod>2025-04-14</lastmod>
61+
<lastmod>2025-04-15</lastmod>
6262
</url>
6363
<url>
6464
<loc>https://bhklab.github.io/med-imagetools/dev/usage/Writers/ImplementingWriters/</loc>
65-
<lastmod>2025-04-14</lastmod>
65+
<lastmod>2025-04-15</lastmod>
6666
</url>
6767
</urlset>

dev/sitemap.xml.gz

0 Bytes
Binary file not shown.

dev/usage/Writers/BaseWriter/index.html

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ <h1 id="abstract-base-writer">Abstract Base Writer</h1>
15941594
<p>The <code>AbstractBaseWriter</code> class is the foundation for all writers in this library.</p>
15951595
<p>It provides a standard interface, reusable methods, and tools that writers can extend
15961596
to handle file writing tasks efficiently and consistently.</p>
1597-
<p>If youre building a writer to manage file outputs with custom paths, filenames, or formats,
1597+
<p>If you're building a writer to manage file outputs with custom paths, filenames, or formats,
15981598
this is where you start!</p>
15991599
<p>For details on implementing the <code>AbstractBaseWriter</code> in your custom writer, see the
16001600
<a href="../ImplementingWriters/">Implementing Writers</a> guide.</p>
@@ -1905,16 +1905,52 @@ <h3 id="index-file-management">Index File Management</h3>
19051905
</ul>
19061906
<p><strong>How It Works</strong>:</p>
19071907
<ul>
1908-
<li>By default, it is named <code>{root_directory.name}_index.csv</code>.</li>
1909-
<li>You can customize the filename or provide an absolute path for more control. </li>
1910-
<li>This is something that the <code>save()</code> method in the <code>AbstractBaseWriter</code> should <strong>optionally</strong>
1911-
implement, or let users decide to include the index by calling <code>add_to_index(path)</code> after <code>save()</code>.</li>
1908+
<li>The AbstractBaseWriter now uses the powerful <code>IndexWriter</code> class to handle all index operations</li>
1909+
<li>By default, the index file is named <code>{root_directory.name}_index.csv</code></li>
1910+
<li>You can customize the filename or provide an absolute path for more control</li>
1911+
<li>When implementing a writer class, call <code>add_to_index(path)</code> in your <code>save()</code> method to record saved files</li>
19121912
</ul>
19131913
<p><strong>Key Features</strong>:</p>
19141914
<ul>
19151915
<li><strong>Customizable Filename</strong>: Use <code>index_filename</code> to set a custom name or absolute path.</li>
1916-
<li><strong>Absolute/Relative Paths</strong>: Control file paths in the index with <code>absolute_paths_in_index</code>.</li>
1917-
<li><strong>Inter-process Locking</strong>: Prevents conflicts in concurrent writing environments.</li>
1916+
<li><strong>Absolute/Relative Paths</strong>: Control file paths in the index with <code>absolute_paths_in_index</code> (defaults to relative).</li>
1917+
<li><strong>Schema Evolution</strong>: Control schema evolution with the <code>merge_columns</code> parameter when calling <code>add_to_index()</code>.</li>
1918+
<li><strong>Safe Concurrent Access</strong>: Uses inter-process locking for thread-safe operations in multi-process environments.</li>
1919+
<li><strong>Robust Error Handling</strong>: Specific exceptions for index-related errors to help troubleshoot issues.</li>
1920+
</ul>
1921+
<p><strong>Using the add_to_index Method</strong>:</p>
1922+
<div class="highlight"><pre><span></span><code><a id="__codelineno-8-1" name="__codelineno-8-1" href="#__codelineno-8-1"></a><span class="c1"># In your writer&#39;s save method:</span>
1923+
<a id="__codelineno-8-2" name="__codelineno-8-2" href="#__codelineno-8-2"></a><span class="k">def</span><span class="w"> </span><span class="nf">save</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">content</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
1924+
<a id="__codelineno-8-3" name="__codelineno-8-3" href="#__codelineno-8-3"></a> <span class="n">output_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">resolve_path</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
1925+
<a id="__codelineno-8-4" name="__codelineno-8-4" href="#__codelineno-8-4"></a>
1926+
<a id="__codelineno-8-5" name="__codelineno-8-5" href="#__codelineno-8-5"></a> <span class="c1"># Write your content to the file...</span>
1927+
<a id="__codelineno-8-6" name="__codelineno-8-6" href="#__codelineno-8-6"></a>
1928+
<a id="__codelineno-8-7" name="__codelineno-8-7" href="#__codelineno-8-7"></a> <span class="c1"># Record this file in the index, with optional parameters:</span>
1929+
<a id="__codelineno-8-8" name="__codelineno-8-8" href="#__codelineno-8-8"></a> <span class="bp">self</span><span class="o">.</span><span class="n">add_to_index</span><span class="p">(</span>
1930+
<a id="__codelineno-8-9" name="__codelineno-8-9" href="#__codelineno-8-9"></a> <span class="n">path</span><span class="o">=</span><span class="n">output_path</span><span class="p">,</span>
1931+
<a id="__codelineno-8-10" name="__codelineno-8-10" href="#__codelineno-8-10"></a> <span class="n">include_all_context</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="c1"># Include all context variables, not just those used in the filename</span>
1932+
<a id="__codelineno-8-11" name="__codelineno-8-11" href="#__codelineno-8-11"></a> <span class="n">filepath_column</span><span class="o">=</span><span class="s2">&quot;path&quot;</span><span class="p">,</span> <span class="c1"># Name of the column to store file paths</span>
1933+
<a id="__codelineno-8-12" name="__codelineno-8-12" href="#__codelineno-8-12"></a> <span class="n">replace_existing</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="c1"># Whether to replace existing entries for the same file</span>
1934+
<a id="__codelineno-8-13" name="__codelineno-8-13" href="#__codelineno-8-13"></a> <span class="n">merge_columns</span><span class="o">=</span><span class="kc">True</span> <span class="c1"># Whether to allow schema evolution</span>
1935+
<a id="__codelineno-8-14" name="__codelineno-8-14" href="#__codelineno-8-14"></a> <span class="p">)</span>
1936+
<a id="__codelineno-8-15" name="__codelineno-8-15" href="#__codelineno-8-15"></a>
1937+
<a id="__codelineno-8-16" name="__codelineno-8-16" href="#__codelineno-8-16"></a> <span class="k">return</span> <span class="n">output_path</span>
1938+
</code></pre></div>
1939+
<p><strong>Schema Evolution with merge_columns</strong>:</p>
1940+
<p>The <code>merge_columns</code> parameter (defaults to <code>True</code>) controls how the IndexWriter handles changes to your data schema:</p>
1941+
<ul>
1942+
<li><strong>When <code>True</code></strong>: If your context has new fields that didn't exist in previous CSV entries, they'll be added as new columns. This is great for:</li>
1943+
<li>Iterative development when you're adding new metadata fields</li>
1944+
<li>Different processes writing files with slightly different context variables</li>
1945+
<li>
1946+
<p>Ensuring backward compatibility with existing index files</p>
1947+
</li>
1948+
<li>
1949+
<p><strong>When <code>False</code></strong>: Strict schema enforcement is applied. The IndexWriter will raise an error if the columns don't match exactly what's already in the index file. This is useful when:</p>
1950+
</li>
1951+
<li>You want to enforce a consistent schema across all entries</li>
1952+
<li>You're concerned about typos or unintended fields creeping into your index</li>
1953+
<li>Data consistency is critical for downstream processing</li>
19181954
</ul>
19191955
<h3 id="sanitizing-filenames">Sanitizing Filenames</h3>
19201956
<p><strong>Why Sanitize Filenames?</strong>:</p>

0 commit comments

Comments
 (0)