Skip to content

Commit 6918c50

Browse files
kian-weimerdzenanz
authored andcommitted
ENH: Added CreateAListOfFileNames Python script
1 parent 1a6ddb3 commit 6918c50

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

src/IO/ImageBase/CreateAListOfFileNames/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ install( FILES Code.cxx CMakeLists.txt
2121
enable_testing()
2222
add_test( NAME CreateAListOfFileNamesTest
2323
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CreateAListOfFileNames )
24+
25+
if(ITK_WRAP_PYTHON)
26+
add_test(NAME CreateAListOfFileNamesTestPython
27+
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Code.py )
28+
endif()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright NumFOCUS
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0.txt
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import itk
18+
19+
numeric_series_file_names = itk.NumericSeriesFileNames.New(
20+
start_index=0, end_index=150, increment_index=10, series_format="output_%d.png"
21+
)
22+
23+
file_names = numeric_series_file_names.GetFileNames()
24+
25+
for file_name in file_names:
26+
print(file_name)
27+
28+
print()
29+
print("***************")
30+
print()
31+
32+
numeric_series_file_names.SetSeriesFormat("output_%04d.png")
33+
34+
file_names = numeric_series_file_names.GetFileNames()
35+
36+
for file_name in file_names:
37+
print(file_name)

src/IO/ImageBase/CreateAListOfFileNames/Documentation.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ Output::
5757
Code
5858
----
5959

60+
Python
61+
......
62+
63+
.. literalinclude:: Code.py
64+
:language: python
65+
:lines: 1, 16-
66+
6067
C++
6168
...
6269

0 commit comments

Comments
 (0)