Question on Accessing Filename of Mimics File

Hello,

I am trying to access the filename of a Mimics project and export an image of the axial view with that filename. I am able to export the image but can’t retrieve the filename of the Mimics project.

Here is the code I am using to export the image:

mimics.file.export_view(filename=path + “7mmRT-.bmp”, view=v_axial, image_type=i_t)

I would like the filename to be "(Mimics project filename) - 7mmRT

1 Like

Hello Stephen,

You can use the function mimics.file.get_project_information() to access multiple data about your project including the project path (that includes the name of the file).

I created a small script as an example that allows you to get the path of your project, to isolate the name of the project and finally to isolate the name without the .mcs:

import os

info = mimics.file.get_project_information()
project_path = info.project_path

# isolate the name from the path
name = os.path.basename(project_path)
print(name)

# remove the .mcs from the name
name = name[0:-4]
print(name)

You can then easily use that name when creating the export path in your script.

Hope this helps!

Clément

2 Likes

That did exactly what I was hoping for! Thank you!