Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmeigh committed Jan 10, 2025
1 parent c7ce611 commit 32302c0
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions mantidimaging/gui/windows/spectrum_viewer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def save_csv(self,
Iterates over all ROIs and saves the spectrum for each one to a CSV file.
@param path: The path to save the CSV file to.
@param normalized: Whether to save the normalized spectrum.
"""
if self._stack is None:
raise ValueError("No stack selected")
Expand Down Expand Up @@ -329,9 +328,10 @@ def save_csv(self,
csv_output.add_column(f"{roi_name}_norm",
self.get_spectrum(roi, SpecType.SAMPLE_NORMED, normalise_with_shuttercount),
"Counts")

with path.open("w") as outfile:
csv_output.write(outfile)
self.save_roi_coords(self.get_roi_coords_filename(path))
self.save_roi_coords(self.get_roi_coords_filename(path), rois)

def save_single_rits_spectrum(self, path: Path, error_mode: ErrorMode, roi: SensibleROI) -> None:
"""
Expand Down Expand Up @@ -463,12 +463,6 @@ def get_roi_coords_filename(self, path: Path) -> Path:
return path.with_stem(f"{path.stem}_roi_coords")

def save_roi_coords(self, path: Path, rois: dict[str, SensibleROI]) -> None:
"""
Save the coordinates of the ROIs to a csv file (ROI name, x_min, x_max, y_min, y_max)
following Pascal VOC format.
@param path: The path to save the CSV file to.
@param rois: A dictionary of ROI names and their coordinates.
"""
with open(path, encoding='utf-8', mode='w') as f:
csv_writer = csv.DictWriter(f, fieldnames=["ROI", "X Min", "X Max", "Y Min", "Y Max"])
csv_writer.writeheader()
Expand All @@ -478,7 +472,7 @@ def save_roi_coords(self, path: Path, rois: dict[str, SensibleROI]) -> None:
"X Min": coords.left,
"X Max": coords.right,
"Y Min": coords.top,
"Y Max": coords.bottom
"Y Max": coords.bottom,
})

def export_spectrum_to_rits(self, path: Path, tof: np.ndarray, transmission: np.ndarray,
Expand Down

0 comments on commit 32302c0

Please sign in to comment.