def _prepare_slices_in_y_orientation(normalized_scan: np.ndarray, scan: Scan) -> None: """Prepare and save Slices in Y orientation. :param normalized_scan: Numpy array with 3D normalized Scan :param scan: Scan object to which new Slices should be added """ for y in range(normalized_scan.shape[1]): location = 100.0 * y / normalized_scan.shape[1] slice_pixels = normalized_scan[:, y, :] _slice = scan.add_slice(SliceOrientation.Y) _slice.update_location(location) _slice.update_size(*slice_pixels.shape) _convert_to_png_and_store(_slice, slice_pixels)
def add_new_scan(category: ScanCategory, number_of_slices: int, user: Optional[User]) -> Scan: """Add new Scan to the database. :param category: Scan's Category object :param number_of_slices: number of Slices that will be uploaded :param user: User that uploaded scan :return: Scan object """ with db_session() as session: scan = Scan(category, number_of_slices, user) session.add(scan) return scan
def add_new_scan(dataset: Dataset, number_of_slices: int, user: User = None) -> Scan: """Add new Scan to the database. :param dataset: Dataset object :param number_of_slices: number of Slices that will be uploaded :param user: (optional) User that uploaded scan :return: Scan object """ scan = Scan(dataset, number_of_slices, user) with db_transaction_session() as session: session.add(scan) return scan