🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Iterating through a flat list *.dcm/*.tag file pairs and applying some processing on each pair

ralph_brecheiseUser: "ralph_brecheise"
New Altair Community Member
Updated by Jocelyn

Hi,

 

I have a flat list of files like this:

 

IM001.dcm

IM001.tag

IM002.dcm

IM002.tag

...

 

I'd like to iterate over this list and apply some processing on each *.dcm/*.tag pair, i.e., inside the "Loop Files" operator I'd like to have access to (IM001.dcm, IM001.tag), (IM002.dcm, IM002.tag), etc.

 

In Python this is easy but I'd like to learn how to do such file manipulation in RM :)

 

Is this possible?

 

Ralph

Find more posts tagged with

Sort by:
1 - 3 of 31
    YYHUser: "YYH"
    Altair Employee
    Accepted Answer

    Hi@ralph_brecheise 

     

    That is also easy with 'loop files' operator in RapidMiner. You can use regex to pick the list of names for .dcm files. And inside the loop you do something 'magic' to create the corresponding '.tag' file name with the Macro creations.

     

    With the newly created file name for .tag  you can do whatever you want to load, extract info from tag.

     

    The number of iteration here is n/2, instead of n for python ;)

    PIC1.PNGPIC2.PNG

    <?xml version="1.0" encoding="UTF-8"?><process version="8.1.000">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="8.1.000" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="concurrency:loop_files" compatibility="8.1.000" expanded="true" height="82" name="Loop Files" width="90" x="916" y="34">
    <parameter key="directory" value="C:\Users\YuanyuanHuang\Documents\RMCommunity\testLoopFiles"/>
    <parameter key="filter_type" value="regex"/>
    <parameter key="filter_by_regex" value=".*dcm"/>
    <parameter key="enable_macros" value="true"/>
    <process expanded="true">
    <operator activated="true" class="image:read_image" compatibility="7.0.000" expanded="true" height="68" name="Read Image" width="90" x="246" y="34"/>
    <operator activated="true" class="generate_macro" compatibility="8.1.000" expanded="true" height="82" name="Generate Macro" width="90" x="380" y="34">
    <list key="function_descriptions">
    <parameter key="tag_file_name" value="concat(prefix(%{file_name},index(%{file_name},&quot;.&quot;)),&quot;.tag&quot;)"/>
    </list>
    </operator>
    <connect from_port="file object" to_op="Read Image" to_port="file"/>
    <connect from_op="Read Image" from_port="output" to_op="Generate Macro" to_port="through 1"/>
    <connect from_op="Generate Macro" from_port="through 1" to_port="output 1"/>
    <portSpacing port="source_file object" spacing="0"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_output 1" spacing="0"/>
    <portSpacing port="sink_output 2" spacing="0"/>
    </process>
    </operator>
    <connect from_op="Loop Files" from_port="output 1" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>
    ralph_brecheiseUser: "ralph_brecheise"
    New Altair Community Member
    OP
    Accepted Answer

    It works!

    YYHUser: "YYH"
    Altair Employee
    Accepted Answer

    @ralph_brecheise  the error message told you there is missing extensions. You will need at least "operator toolbox", "converters" extensions from marketplace.

     

    Any questions, please let us know.