MONAILabel: Incorrect filename truncation

Describe the bug

When I use the Next Sample button, the retrieved displayed volume name is incorrect. That’s because i believe parser incorrectly cuts at the volume name at “-” sign of the volume. Below is the log from the python interactor, displaying the correct volume name. In slicer, regardless of the volume, all retrieved volumes are displayed as 15.5_baseline in Slicer, which confuses the user.

Check if file exists/shared locally: /workspace/undeterminedSex_AAMN_N305-17-e15.5_baseline.nii.gz => False
http://127.0.0.1:8000/datastore/image?image=undeterminedSex_AAMN_N305-17-e15.5_baseline

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 23 (10 by maintainers)

Commits related to this issue

Most upvoted comments

it may make sense to add a small button (it could be just a “copy” icon) for copying the filename to the clipboard. Maybe it could be a generally useful feature.

It’s an interesting point - we could add subject hierarchy-style context menus to ctkComboBox instances. Currently these kinds of options are at the bottom of the combo box list, which works but isn’t perfect. We could also add an option to the subject hierarchy to copy filename/path.

I’m a researcher, not a developer

Thanks for your feedback @pwrightkcl - it’s important to figure out how to make the tools work well in real-world scenarios. The MONAIL Label project is still fairly new so there are many things to smooth out.

You don’t need to install the plugin manually, just install it as usual and modify the files locally as needed. If you reinstall MONAILabel today then you’ll get the elided combobox, so you can just make your suggested modification to test if everything works well. After you have a solution that you tested and works well for you then please submit a pull request. Thank you!

I’ve pushed a change that makes the node name displayed with eliding the center:

https://github.com/Project-MONAI/MONAILabel/pull/841

Could you please check if it solves your problem? (just need to change a few lines in the MONAILabel module’s .ui file)

Thank you, this description was very useful.

The clinician wants to be able to note images where the model struggles to produce good labels, for example there is an unusual lesion, or the image has a bad artefact. This is where he needs a filename or another way to identify individual images.

This is a very common need. I think in MONAILabelReview there is already support for adding notes to labeled images when they are uploaded to the server. Until it becomes available in MONAILabel, there are several quick workarounds.

Is there anywhere the node name is shown in copyable form?

Probably the easiest is the Data module. You can double-click on the node name and then hit Ctrl-C to copy it to the clipboard.

I could, for the sake of the Slicer MONAI label plug in, rename all the images to < 20 characters, but I would need to keep a key and revert the names of the resulting labels to match the original filenames. That creates extra work that I would prefer to avoid.

If you use folder structure to organize your data then indeed you cannot do much about this. It is easier to handle the long names in the application than complicating things by keeping multiple copies of files with shortened names.

I agree as @lassoan said…

for example, u might just need some copy action button (instead of displaying long name) somewhere in the Tools section of monailabel plugin…

may be you can explain your post actions. there may be a simple ways to get it done

All I wanted was for the MONAI label plugin to let Slicer handle the filename the way it usually does, and only truncate it in the MONAI label Master Volume dropdown, instead of truncating it throughout Slicer.

There is a difference between the user loading a file from a folder where that data persistently stored; and loading a file from a temporary folder (for example a folder that stores temporary data that is downloaded from a server). The filename should be cleared or set to a random string if it is read from a temporary location. It looks like MONAILabel clears the filename (you can see that in Volumes module), so I think MONAILabel sets the filename correctly.

The node name is often displayed on screen and therefore it is better to keep it short (10-20 characters). If MONAILabel tends to create long filenames then that may worth revisiting (e.g., if it adds a suffix then use seg instead of segmentation). However, long node names should not cause too much trouble for modules. If MONAILabel does not show long node names well (e.g., clips the end or makes the GUI layout very wide) then that could be improved (e.g., always elide the middle of long strings). But none of these seem to make a dramatic difference for the workflows that I have in mind.

@pwrightkcl could you describe your workflow and the reason for having long names and the reasons for needing to see them? Do you really just need to see them or copy them to some other locations or cross-reference them with some other data,…? We may find a much better solution to your needs than just displaying longer names.

All I wanted was for the MONAI label plugin to let Slicer handle the filename the way it usually does, and only truncate it in the MONAI label Master Volume dropdown, instead of truncating it throughout Slicer.

I’ve had a look at the code @diazandr3s shared, but I haven’t done any coding in Slicer, and I’m having to absorb gallons of object definitions to orient myself here. I’m a researcher, not a developer, and this is turning into a task that will eat up half my day, so I’m giving up.

Combobox sizing is a surprisingly complicated topic. Having a long string in a comobox can mess up layouts. So, in general you cannot just let strings displayed without some kind of control over the displayed length.

One option is to shorten the strings, but I agree that it can be problematic, because you may want to store a lot of relevant information there.

Another option is to use eliding (remove beginning, middle, or end of the string and replace with ...). Qt’s stock QComboBox does not support eliding, but in ctkComboBox and derived classes you can enable eliding using the elideMode property.

As a side note, filename should be generally limited to a few ten characters because total file path length is quite short on Windows (depending on what file access API isand file system is used).

If your workflow relies on the user taking note of filenames then it may make sense to add a small button (it could be just a “copy” icon) for copying the filename to the clipboard. Maybe it could be a generally useful feature.

This one looks ok due to single window in the viewer… try default 4 split window (3d view)… and 100 char filename…

My be in your use case u don’t have more than 100 chars. I have a simple suggestion… this can be done with a small code changes…

  1. Add a settings flag to show full filename
  2. When you creat the volume node… you can set the full or truncated based on the above flag.

If you can help to get a pR, we can review and add this fix to main branch for all general purpose users

Currently logs can help you to get full details… u can see them under python console inside slicer… Or as suggested by @lassoan … if you can add a small fix to add tooltip and raise a PR… will be helpful