Create a filename based on the input ``subject`` and ``idx``. The output filename is formed as: ``output_dir/[subject/]subject[_postfix][_idx][_key-value][ext]`` Args: subject: subject name, used as the primary id of the output filename.
(self, subject: PathLike = "subject", idx=None, **kwargs)
| 135 | self.data_root_dir = data_root_dir |
| 136 | |
| 137 | def filename(self, subject: PathLike = "subject", idx=None, **kwargs) -> PathLike: |
| 138 | """ |
| 139 | Create a filename based on the input ``subject`` and ``idx``. |
| 140 | |
| 141 | The output filename is formed as: |
| 142 | |
| 143 | ``output_dir/[subject/]subject[_postfix][_idx][_key-value][ext]`` |
| 144 | |
| 145 | Args: |
| 146 | subject: subject name, used as the primary id of the output filename. |
| 147 | When a `PathLike` object is provided, the base filename will be used as the subject name, |
| 148 | the extension name of `subject` will be ignored, in favor of ``extension`` |
| 149 | from this class's constructor. |
| 150 | idx: additional index name of the image. |
| 151 | kwargs: additional keyword arguments to be used to form the output filename. |
| 152 | The key-value pairs will be appended to the output filename as ``f"_{k}-{v}"``. |
| 153 | """ |
| 154 | full_name = create_file_basename( |
| 155 | postfix=self.postfix, |
| 156 | input_file_name=subject, |
| 157 | folder_path=self.output_dir, |
| 158 | data_root_dir=self.data_root_dir, |
| 159 | separate_folder=self.parent, |
| 160 | patch_index=idx, |
| 161 | makedirs=self.makedirs, |
| 162 | ) |
| 163 | for k, v in kwargs.items(): |
| 164 | full_name += f"_{k}-{v}" |
| 165 | if self.ext is not None: |
| 166 | ext = f"{self.ext}" |
| 167 | full_name += f".{ext}" if ext and not ext.startswith(".") else f"{ext}" |
| 168 | return full_name |
no test coverage detected