How to tell Slicer to save by default in whatever folder it is called from

I use Slicer on Linux a lot, and I usually invoke it from the terminal window and typically from the folder where the dataset I am going to work on is present. I would like to have the default save behavior to be in the same folder (so something like “./”, or $PWD) but I can’t seem to type a field in the ‘default save scene folder’ under settings. Is there a place to set this in .slicerrc.py or some other initialization script?

Default scene location is a directory selector button. You can click on it to change the default scene location. It is also can be read/written from Python as slicer.app.defaultScenePath.

1 Like

In case it wasn’t clear, Andras is referring to this button in the Application Settings.

@lassoan @pieper,

Yes, that’s the setting that I was talking about. neither in Windows nor Linux it accepts relative path. It is not an editable field for me to put something like “./”. It reverts to the full path of that where working directory I am, and hard codes. So next time I start in a different working directory, it will be wrong again. Anyways, I think python solution might be more relevant. Get the $PWD from the os, and set it as the default scene location.

Default scene save path would be something like your “documents” folder. It should not be overwritten each time you run a script from some random working directory.

Instead, if you want to change the default save location in a scripting session then modify the root directory of the scene. For example, you can set it to the current working directory by calling slicer.mrmlScene.SetRootDirectory(os.getcwd()).

I think it depends on what you want to do. I personally do not have any use for a ‘documents’ folder as a default save location. I would prefer if the behavior is to make the default save path to the location of current (or last loaded) dataset. In my experience the setting ‘default scene path’ to Documents (or like) doesn’t just effect the scenes, but any new volume or data that gets created in the scene by default get the same path. Again everybody has different use cases, and I understand it is hard to find a solution that’s going to fit everyone. I think python manipulation is going to work for me.

Current Slicer behavior follows common convention used by applications such as MS Office (new files are always saved to “documents” folder by default; existing files are saved to their current location).

It is impossible to meet expectations of all users with a single behavior, that’s why all the customization options are made available.