Closed j-onne closed 4 months ago
The files are saved in this method, you can modify that: https://github.com/DIAGNijmegen/rse-panimg/blob/6d45a8cdec5d0feedfc1047eb86fc3a94e17573d/panimg/models.py#L355
Hi, Thank you for directing me towards that, changed the code.
def save(self, output_directory: Path) -> Tuple[PanImg, Set[PanImgFile]]:
pk = uuid4()
# output_file = output_directory / self.name / f"{pk}{self.file.suffix}"
# output_file.parent.mkdir()
new_image = PanImg(
pk=pk,
name=self.name,
width=self.width,
height=self.height,
depth=self.depth,
window_center=self.window_center,
window_width=self.window_width,
timepoints=self.timepoints,
resolution_levels=None,
color_space=self.color_space,
voxel_width_mm=self.voxel_width_mm,
voxel_height_mm=self.voxel_height_mm,
voxel_depth_mm=self.voxel_depth_mm,
eye_choice=self.eye_choice,
segments=self.segments,
**self.generate_extra_metadata(),
)
# Save the image with the name specified by the 'name' attribute
WriteImage(
image=self.image,
fileName=str(output_directory.absolute() / f"{self.name}.mha"),
useCompression=True,
)
new_files = set()
# Create PanImgFile objects for each file in the output_directory
for file in output_directory.iterdir():
new_file = PanImgFile(
image_id=pk, image_type=ImageType.MHD, file=file
)
new_files.add(new_file)
return new_image, new_files
However I now get the following error: WriteImage() got an unexpected keyword argument 'image' What am i doing wrong. Thank you in advance!
Okay, i uninstalled and reinstall the package, but i still get the same error: WriteImage() got an unexpected keyword argument 'image'. I checked and the models file is indeed restored to the original models file.
I can't really help you debug your own code/environment, sorry.
Hi okay, no worries. don't really understand why the original package doesn't work now either...
How can i change the title of the mha file it produces (to the name of the orginal file)? Additionally i would also like to change the folder where the new mha file it being dropped into (or ideally, even completly eliminate the folder and put all new mha directly files into the output directory).
I tried to change the code of the panimg python file. specifically of the builder function however the packages stopped working after that. It there a build in way, that can achieve this?