def push_zero_projections(resolution, host="localhost", port=5558): m = resolution proj_count, rows, cols = m, m, m scene_id = 0 pub = tomop.publisher(host, port) # We let the server know we will send one dark field, and one flat field num_darks, num_flats = 1, 1 packet_scan_settings = tomop.scan_settings_packet(scene_id, num_darks, num_flats, False) pub.send(packet_scan_settings) # Initialize volume and acquisition geometry packet_vol_geom = tomop.geometry_specification_packet( scene_id, [0, 0, 0], [1, 1, 1]) pub.send(packet_vol_geom) angles = np.linspace(0, np.pi, proj_count, endpoint=False) packet_geometry = tomop.parallel_beam_geometry_packet( scene_id, rows, cols, proj_count, angles) pub.send(packet_geometry) # Send dark(s) and flat(s) dark = np.zeros((rows, cols), dtype=np.float32).ravel() packet_dark = tomop.projection_packet(0, 0, [rows, cols], dark) pub.send(packet_dark) flat = np.ones((rows, cols), dtype=np.float32).ravel() packet_flat = tomop.projection_packet(1, 0, [rows, cols], flat) pub.send(packet_flat) # Create and send projection data consisting of zeros proj_data = np.zeros((proj_count, rows, cols)) for i in np.arange(0, proj_count): packet_proj = tomop.projection_packet(2, i, [rows, cols], proj_data[i, :, :].ravel()) pub.send(packet_proj)
pub = tomop.publisher(args.host, args.port) path = args.path # PACKET 1: object volume specification print("Sending object volume") geom_spec = tomop.geometry_specification_packet(0, [-n / 2, -n / 2, -n / 2], [n / 2, n / 2, n / 2]) pub.send(geom_spec) # PACKET 2: acquisition geometry print("Sending acquisition geometry") par_beam = tomop.parallel_beam_geometry_packet(0, m, n, count, angles) pub.send(par_beam) # PACKET 3: scan settings print("Sending scan data (linear: ", not args.linearize, ")") pub.send(tomop.scan_settings_packet(0, 0, 0, not args.linearize)) # PACKET 4..: Projections while not os.path.isfile(files[0][1]): time.sleep(0.01) time.sleep(1.0) shape, first_proj = ser_parser.parser(files[0][1]) prev = np.reshape(first_proj, [m, n]) prev = np.transpose(prev, axes=[1, 0]) def center(xs): val = ski.filters.threshold_otsu(xs) ys = xs.copy()
print(proj_geom) print('proj geom vector count', len(proj_geom['Vectors'])) print(vol_geom) packet_vol_geom = tomop.geometry_specification_packet(0, [ vol_geom['option']['WindowMinX'], vol_geom['option']['WindowMinY'], vol_geom['option']['WindowMinZ'] ], [ vol_geom['option']['WindowMaxX'], vol_geom['option']['WindowMaxY'], vol_geom['option']['WindowMaxZ'] ]) if not args.skipgeometry: pub.send(packet_vol_geom) print("flat dark", flat.shape, dark.shape) packet_scan_settings = tomop.scan_settings_packet(0, dark.shape[1], flat.shape[1], False) if not args.skipgeometry: pub.send(packet_scan_settings) packet_geometry = tomop.cone_vec_geometry_packet( 0, rows, cols, proj_count, proj_geom['Vectors'].flatten()) if not args.skipgeometry: pub.send(packet_geometry) # send darks (0), lights (1), projs (2) for i in np.arange(0, dark.shape[1]): packet_dark = tomop.projection_packet( 0, i, [rows, cols], np.ascontiguousarray(dark[:, i, :].flatten())) pub.send(packet_dark)
print(proj_geom) print('proj geom vector count', len(proj_geom['Vectors'])) print(vol_geom) packet_vol_geom = tomop.geometry_specification_packet(0, [ vol_geom['option']['WindowMinX'], vol_geom['option']['WindowMinY'], vol_geom['option']['WindowMinZ'] ], [ vol_geom['option']['WindowMaxX'], vol_geom['option']['WindowMaxY'], vol_geom['option']['WindowMaxZ'] ]) if not args.skipgeometry: pub.send(packet_vol_geom) packet_scan_settings = tomop.scan_settings_packet(0, dark.shape[0], flat.shape[0]) if not args.skipgeometry: pub.send(packet_scan_settings) packet_geometry = tomop.cone_vec_geometry_packet( 0, rows, cols, proj_count, proj_geom['Vectors'].flatten()) if not args.skipgeometry: pub.send(packet_geometry) # send darks (0), lights (1), projs (2) for i in np.arange(0, dark.shape[0]): packet_dark = tomop.projection_packet( 0, i, [rows, cols], np.ascontiguousarray(dark[i, :, :].flatten())) pub.send(packet_dark)
parser.add_argument('--time', type=float, default=0.0, help='time interval') parser.add_argument('--projs', type=int, help='proj count') args = parser.parse_args() hdf5Reader = Hdf5ReaderClass(args.path) proj = hdf5Reader.getRawImage(0) rows, cols = proj.shape pub = tp.publisher(args.host, args.port) pub.send( tp.scan_settings_packet(0, hdf5Reader.numberOfDarks, hdf5Reader.totalNumberOfFlats // 2, False)) r = max(rows, cols) window_min_point = [-cols // 2, -cols // 2, -rows // 2] window_max_point = [cols // 2, cols // 2, rows // 2] pub.send( tp.geometry_specification_packet(0, window_min_point, window_max_point)) angles = np.linspace(0, np.pi, args.projs, endpoint=False) pub.send( tp.parallel_beam_geometry_packet(0, rows, cols, args.projs, angles)) for i in range(hdf5Reader.numberOfDarks): packet_dark = tp.projection_packet( 0, i, [rows, cols],