def create_backprojection3d_gpu(data, proj_geom, vol_geom, returnData=True): """Create a backprojection of a sinogram (3D) using CUDA. :param data: Sinogram data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_geom: Projection geometry. :type proj_geom: :class:`dict` :param vol_geom: Volume geometry. :type vol_geom: :class:`dict` :param returnData: If False, only return the ID of the backprojection. :type returnData: :class:`bool` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the backprojection. Otherwise, returns a tuple containing the ID of the backprojection and the backprojection itself, in that order. """ if isinstance(data, np.ndarray): sino_id = data3d.create("-sino", proj_geom, data) else: sino_id = data vol_id = data3d.create("-vol", vol_geom, 0) cfg = astra_dict("BP3D_CUDA") cfg["ProjectionDataId"] = sino_id cfg["ReconstructionDataId"] = vol_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data3d.delete(sino_id) if returnData: return vol_id, data3d.get(vol_id) else: return vol_id
def pressed(self): print "Start calculations" try: print self.filename print self.sheet_listbox.get(self.sheet_listbox.curselection()) distance_maker = d_counter.Counter(self.filename,self.sheet_listbox.get(self.sheet_listbox.curselection())) self.dendrite_data = distance_maker.get_distance_matrix() print "ddata", self.dendrite_data self.set_objects_mapping(distance_maker.objects) alg.run(self.dendrite_data, self.metric_listbox.get(self.metric_listbox.curselection()), self.objects_mapping) except (IndexError, TclError, IOError) as e: print "Error:", e tkMessageBox.showinfo("Błąd", "Wybierz poprawny plik, arkusz excela i sposób liczenia odleglości między grupami. {}".format(e))
def create_sino(data, proj_id, useCUDA=False, returnData=True, gpuIndex=None): """Create a forward projection of an image (2D). :param data: Image data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_id: ID of the projector to use. :type proj_id: :class:`int` :param useCUDA: If ``True``, use CUDA for the calculation. :type useCUDA: :class:`bool` :param returnData: If False, only return the ID of the forward projection. :type returnData: :class:`bool` :param gpuIndex: Optional GPU index. :type gpuIndex: :class:`int` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the forward projection. Otherwise, returns a tuple containing the ID of the forward projection and the forward projection itself, in that order. """ proj_geom = projector.projection_geometry(proj_id) vol_geom = projector.volume_geometry(proj_id) if isinstance(data, np.ndarray): volume_id = data2d.create("-vol", vol_geom, data) else: volume_id = data sino_id = data2d.create("-sino", proj_geom, 0) algString = "FP" if useCUDA: algString = algString + "_CUDA" cfg = astra_dict(algString) if not useCUDA: cfg["ProjectorId"] = proj_id if not gpuIndex == None: cfg["option"] = {"GPUindex": gpuIndex} cfg["ProjectionDataId"] = sino_id cfg["VolumeDataId"] = volume_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data2d.delete(volume_id) if returnData: return sino_id, data2d.get(sino_id) else: return sino_id
def create_sino(data, proj_id, useCUDA=False, returnData=True, gpuIndex=None): """Create a forward projection of an image (2D). :param data: Image data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_id: ID of the projector to use. :type proj_id: :class:`int` :param useCUDA: If ``True``, use CUDA for the calculation. :type useCUDA: :class:`bool` :param returnData: If False, only return the ID of the forward projection. :type returnData: :class:`bool` :param gpuIndex: Optional GPU index. :type gpuIndex: :class:`int` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the forward projection. Otherwise, returns a tuple containing the ID of the forward projection and the forward projection itself, in that order. """ proj_geom = projector.projection_geometry(proj_id) vol_geom = projector.volume_geometry(proj_id) if isinstance(data, np.ndarray): volume_id = data2d.create('-vol', vol_geom, data) else: volume_id = data sino_id = data2d.create('-sino', proj_geom, 0) algString = 'FP' if useCUDA: algString = algString + '_CUDA' cfg = astra_dict(algString) if not useCUDA: cfg['ProjectorId'] = proj_id if not gpuIndex==None: cfg['option']={'GPUindex':gpuIndex} cfg['ProjectionDataId'] = sino_id cfg['VolumeDataId'] = volume_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data2d.delete(volume_id) if returnData: return sino_id, data2d.get(sino_id) else: return sino_id
def create_backprojection(data, proj_id, useCUDA=False, returnData=True): """Create a backprojection of a sinogram (2D). :param data: Sinogram data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_id: ID of the projector to use. :type proj_id: :class:`int` :param useCUDA: If ``True``, use CUDA for the calculation. :type useCUDA: :class:`bool` :param returnData: If False, only return the ID of the backprojection. :type returnData: :class:`bool` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the backprojection. Otherwise, returns a tuple containing the ID of the backprojection and the backprojection itself, in that order. """ proj_geom = projector.projection_geometry(proj_id) vol_geom = projector.volume_geometry(proj_id) if isinstance(data, np.ndarray): sino_id = data2d.create("-sino", proj_geom, data) else: sino_id = data vol_id = data2d.create("-vol", vol_geom, 0) algString = "BP" if useCUDA: algString = algString + "_CUDA" cfg = astra_dict(algString) if not useCUDA: cfg["ProjectorId"] = proj_id cfg["ProjectionDataId"] = sino_id cfg["ReconstructionDataId"] = vol_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data2d.delete(sino_id) if returnData: return vol_id, data2d.get(vol_id) else: return vol_id
def create_backprojection(data, proj_id, useCUDA=False, returnData=True): """Create a backprojection of a sinogram (2D). :param data: Sinogram data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_id: ID of the projector to use. :type proj_id: :class:`int` :param useCUDA: If ``True``, use CUDA for the calculation. :type useCUDA: :class:`bool` :param returnData: If False, only return the ID of the backprojection. :type returnData: :class:`bool` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the backprojection. Otherwise, returns a tuple containing the ID of the backprojection and the backprojection itself, in that order. """ proj_geom = projector.projection_geometry(proj_id) vol_geom = projector.volume_geometry(proj_id) if isinstance(data, np.ndarray): sino_id = data2d.create('-sino', proj_geom, data) else: sino_id = data vol_id = data2d.create('-vol', vol_geom, 0) algString = 'BP' if useCUDA: algString = algString + '_CUDA' cfg = astra_dict(algString) if not useCUDA: cfg['ProjectorId'] = proj_id cfg['ProjectionDataId'] = sino_id cfg['ReconstructionDataId'] = vol_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data2d.delete(sino_id) if returnData: return vol_id, data2d.get(vol_id) else: return vol_id
def data_op(op, data, scalar, gpu_core, mask=None): """Perform data operation on data. :param op: Operation to perform. :param data: Data to perform operation on. :param scalar: Scalar argument to data operation. :param gpu_core: GPU core to perform operation on. :param mask: Optional mask. """ cfg = ac.astra_dict('DataOperation_CUDA') cfg['Operation'] = op cfg['Scalar'] = scalar cfg['DataId'] = data if not mask == None: cfg['MaskId'] = mask cfg['option']['GPUindex'] = gpu_core alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id)
def create_sino3d_gpu(data, proj_geom, vol_geom, returnData=True, gpuIndex=None): """Create a forward projection of an image (3D). :param data: Image data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_geom: Projection geometry. :type proj_geom: :class:`dict` :param vol_geom: Volume geometry. :type vol_geom: :class:`dict` :param returnData: If False, only return the ID of the forward projection. :type returnData: :class:`bool` :param gpuIndex: Optional GPU index. :type gpuIndex: :class:`int` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the forward projection. Otherwise, returns a tuple containing the ID of the forward projection and the forward projection itself, in that order. """ if isinstance(data, np.ndarray): volume_id = data3d.create('-vol', vol_geom, data) else: volume_id = data sino_id = data3d.create('-sino', proj_geom, 0) algString = 'FP3D_CUDA' cfg = astra_dict(algString) if not gpuIndex==None: cfg['option']={'GPUindex':gpuIndex} cfg['ProjectionDataId'] = sino_id cfg['VolumeDataId'] = volume_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data3d.delete(volume_id) if returnData: return sino_id, data3d.get(sino_id) else: return sino_id
def create_sino3d_gpu(data, proj_geom, vol_geom, returnData=True, gpuIndex=None): """Create a forward projection of an image (3D). :param data: Image data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_geom: Projection geometry. :type proj_geom: :class:`dict` :param vol_geom: Volume geometry. :type vol_geom: :class:`dict` :param returnData: If False, only return the ID of the forward projection. :type returnData: :class:`bool` :param gpuIndex: Optional GPU index. :type gpuIndex: :class:`int` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the forward projection. Otherwise, returns a tuple containing the ID of the forward projection and the forward projection itself, in that order. """ if isinstance(data, np.ndarray): volume_id = data3d.create("-vol", vol_geom, data) else: volume_id = data sino_id = data3d.create("-sino", proj_geom, 0) algString = "FP3D_CUDA" cfg = astra_dict(algString) if not gpuIndex == None: cfg["option"] = {"GPUindex": gpuIndex} cfg["ProjectionDataId"] = sino_id cfg["VolumeDataId"] = volume_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data3d.delete(volume_id) if returnData: return sino_id, data3d.get(sino_id) else: return sino_id
def run_algorithm(): if request.method == 'POST': CENTROIDS = int(request.form['centroids']) MANPOWER = int(request.form['manpower']) ID = [i for (i, ) in db.session.query(Village.id).all()] XCOORDINATES = [ i for (i, ) in db.session.query(Village.longitude).all() ] YCOORDINATES = [ i for (i, ) in db.session.query(Village.latitude).all() ] POPULATION = [ i for (i, ) in db.session.query(Village.population).all() ] VILLAGES, CENTERS = algorithm.run(ID, XCOORDINATES, YCOORDINATES, POPULATION, CENTROIDS, MANPOWER) for i in range(len(ID)): village = Village.query.get_or_404(int(VILLAGES['id'][i])) village.assigned_center = int(VILLAGES['colorID'][i]) # delete existing centers from previous runs try: db.session.query(Center).delete() db.session.commit() except: return 'There was an issue deleting your village' for i in range(len(CENTERS['colorID'])): new_center = Center(colorID=int(CENTERS['colorID'][i]), longitude=CENTERS['x'][i], latitude=CENTERS['y'][i], manpower=int(CENTERS['manpower'][i])) try: db.session.add(new_center) except: 'oops' try: db.session.commit() return redirect('/database') #CHANGE TO HOMEPAGE except: return 'There was an issue running the algorithm' else: return render_template('run.html')
def sendSecondEmail(to, content): try: algorithm_results = run(content) except: print("sending email to: " + to + " with content: " + content + " failed") return msg = MIMEText("And the top results are:\n" + algorithm_results) msg['Subject'] = "Search request results" msg['From'] = "*****@*****.**" msg['To'] = to s = smtplib.SMTP('smtp.mailgun.org', 587) s.login('*****@*****.**', '06622845eb4a6500758ff47bf996cf19-060550c6-e56db87b') s.sendmail(msg['From'], msg['To'], msg.as_string()) s.quit()
import algorithm from must_link import MustLinkConstraint from cannot_link import CannotLinkConstraint from evidence import Evidence from gaussian import Gaussian from dataset import * gaussians = generate_initial_gaussians(20, 10, 100) evidence = generate_evidence() must_link = [] cannot_link = [] options = dict() options['ITERATIONS'] = 5 options['SAVE_PROGRESS_PNGS'] = False options['SHOW_FINAL_PLOT'] = True options['MIN_STANDARD_DEVIATION'] = 0.5 options['PRINT_CLUSTERS'] = True options['DEBUG_OUTPUT'] = False options['PRINT_PROGRESS'] = True algorithm.run(gaussians, evidence, must_link, cannot_link, options)
def get(self, query): words = query.split('+') result = run(words) return {'res': result}
def create_reconstruction(rec_type, proj_id, sinogram, iterations=1, use_mask='no', mask=np.array([]), use_minc='no', minc=0, use_maxc='no', maxc=255, returnData=True, filterType=None, filterData=None): """Create a reconstruction of a sinogram (2D). :param rec_type: Name of the reconstruction algorithm. :type rec_type: :class:`string` :param proj_id: ID of the projector to use. :type proj_id: :class:`int` :param sinogram: Sinogram data or ID. :type sinogram: :class:`numpy.ndarray` or :class:`int` :param iterations: Number of iterations to run. :type iterations: :class:`int` :param use_mask: Whether to use a mask. :type use_mask: ``'yes'`` or ``'no'`` :param mask: Mask data or ID :type mask: :class:`numpy.ndarray` or :class:`int` :param use_minc: Whether to force a minimum value on the reconstruction pixels. :type use_minc: ``'yes'`` or ``'no'`` :param minc: Minimum value to use. :type minc: :class:`float` :param use_maxc: Whether to force a maximum value on the reconstruction pixels. :type use_maxc: ``'yes'`` or ``'no'`` :param maxc: Maximum value to use. :type maxc: :class:`float` :param returnData: If False, only return the ID of the reconstruction. :type returnData: :class:`bool` :param filterType: Which type of filter to use for filter-based methods. :type filterType: :class:`string` :param filterData: Optional filter data for filter-based methods. :type filterData: :class:`numpy.ndarray` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the reconstruction. Otherwise, returns a tuple containing the ID of the reconstruction and reconstruction itself, in that order. """ proj_geom = projector.projection_geometry(proj_id) if isinstance(sinogram, np.ndarray): sino_id = data2d.create('-sino', proj_geom, sinogram) else: sino_id = sinogram vol_geom = projector.volume_geometry(proj_id) recon_id = data2d.create('-vol', vol_geom, 0) cfg = astra_dict(rec_type) if not 'CUDA' in rec_type: cfg['ProjectorId'] = proj_id cfg['ProjectionDataId'] = sino_id cfg['ReconstructionDataId'] = recon_id cfg['options'] = {} if use_mask == 'yes': if isinstance(mask, np.ndarray): mask_id = data2d.create('-vol', vol_geom, mask) else: mask_id = mask cfg['options']['ReconstructionMaskId'] = mask_id if not filterType == None: cfg['FilterType'] = filterType if not filterData == None: if isinstance(filterData, np.ndarray): nexpow = int( pow(2, math.ceil(math.log(2 * proj_geom['DetectorCount'], 2)))) filtSize = nexpow / 2 + 1 filt_proj_geom = create_proj_geom( 'parallel', 1.0, filtSize, proj_geom['ProjectionAngles']) filt_id = data2d.create('-sino', filt_proj_geom, filterData) else: filt_id = filterData cfg['FilterSinogramId'] = filt_id cfg['options']['UseMinConstraint'] = use_minc cfg['options']['MinConstraintValue'] = minc cfg['options']['UseMaxConstraint'] = use_maxc cfg['options']['MaxConstraintValue'] = maxc cfg['options']['ProjectionOrder'] = 'random' alg_id = algorithm.create(cfg) algorithm.run(alg_id, iterations) algorithm.delete(alg_id) if isinstance(sinogram, np.ndarray): data2d.delete(sino_id) if use_mask == 'yes' and isinstance(mask, np.ndarray): data2d.delete(mask_id) if not filterData == None: if isinstance(filterData, np.ndarray): data2d.delete(filt_id) if returnData: return recon_id, data2d.get(recon_id) else: return recon_id
def main(args): birch_thresh = args.birch_thresh window_size = args.window_size input_directory = args.inputchains output_directory = args.outputchains per_day_data = args.perdaydata print("Running algorithm") if args.plotgraph: result = [] precision = [] recall = [] f_measure = [] highest_f1_score = 0 window_sizes = range(2, 21, 2) for window_size in window_sizes: print("Running for window Size", window_size) algorithm.run(per_day_data, output_directory, birch_thresh, window_size) temp_result = evaluate_algorithm.run( input_directory, output_directory) precision.append(temp_result[0]) recall.append(temp_result[1]) f_measure.append(temp_result[2]) if temp_result[3] > highest_f1_score: highest_f1_score = temp_result[3] result = temp_result result.insert(0, birch_thresh) result.insert(0, window_size) delete_files(output_directory) with open('windowsizes', 'wb') as fp: pickle.dump(window_sizes, fp) with open('precision', 'wb') as fp: pickle.dump(precision, fp) with open('recall', 'wb') as fp: pickle.dump(recall, fp) with open('fmeasure', 'wb') as fp: pickle.dump(f_measure, fp) plot_results.plot_score_with_window_size() print('Highest F1 Score for these parameters: Window Size: {}, Birch Threshold: {}. Result- Precision: {:.2f}, Recall: {:.2f}, F1-Score: {:.2f}, NMI: {:.2f}, ARI: {:.2f}'.format( result[0], result[1], result[2], result[3], result[4], result[5], result[6])) else: algorithm.run(per_day_data, output_directory, birch_thresh, window_size) result = evaluate_algorithm.run(input_directory, output_directory) print('Window Size: {}, Birch Threshold: {}, Precision: {:.2f}, Recall: {:.2f}, F1-Score: {:.2f}, NMI: {:.2f}, ARI: {:.2f}'.format( window_size, birch_thresh, result[0], result[1], result[2], result[3], result[4])) if args.plotactivechains: plot_results.plot_active_events(input_directory, output_directory)
def create_sino(data, proj_id=None, proj_geom=None, vol_geom=None, useCUDA=False, returnData=True, gpuIndex=None): """Create a forward projection of an image (2D). :param data: Image data or ID. :type data: :class:`numpy.ndarray` or :class:`int` :param proj_id: ID of the projector to use. :type proj_id: :class:`int` :param proj_geom: Projection geometry. :type proj_geom: :class:`dict` :param vol_geom: Volume geometry. :type vol_geom: :class:`dict` :param useCUDA: If ``True``, use CUDA for the calculation. :type useCUDA: :class:`bool` :param returnData: If False, only return the ID of the forward projection. :type returnData: :class:`bool` :param gpuIndex: Optional GPU index. :type gpuIndex: :class:`int` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) If ``returnData=False``, returns the ID of the forward projection. Otherwise, returns a tuple containing the ID of the forward projection and the forward projection itself, in that order. The geometry of setup is defined by ``proj_id`` or with ``proj_geom`` and ``vol_geom``. If ``proj_id`` is given, then ``proj_geom`` and ``vol_geom`` must be None and vice versa. """ if proj_id is not None: proj_geom = projector.projection_geometry(proj_id) vol_geom = projector.volume_geometry(proj_id) elif proj_geom is not None and vol_geom is not None: if not useCUDA: # We need more parameters to create projector. raise ValueError( """A ``proj_id`` is needed when CUDA is not used.""") else: raise Exception("""The geometry setup is not defined. The geometry of setup is defined by ``proj_id`` or with ``proj_geom`` and ``vol_geom``. If ``proj_id`` is given, then ``proj_geom`` and ``vol_geom`` must be None and vice versa.""") if isinstance(data, np.ndarray): volume_id = data2d.create('-vol', vol_geom, data) else: volume_id = data sino_id = data2d.create('-sino', proj_geom, 0) algString = 'FP' if useCUDA: algString = algString + '_CUDA' cfg = astra_dict(algString) if not useCUDA: cfg['ProjectorId'] = proj_id if gpuIndex is not None: cfg['option'] = {'GPUindex': gpuIndex} cfg['ProjectionDataId'] = sino_id cfg['VolumeDataId'] = volume_id alg_id = algorithm.create(cfg) algorithm.run(alg_id) algorithm.delete(alg_id) if isinstance(data, np.ndarray): data2d.delete(volume_id) if returnData: return sino_id, data2d.get(sino_id) else: return sino_id
from algorithm import run import os import json name = input("name:") filename = name+".json" file = os.path.join("./config", filename) with open(file, "r") as f: datas = json.load(f)["setting"] for data in datas: run(*data)
def create_reconstruction( rec_type, proj_id, sinogram, iterations=1, use_mask="no", mask=np.array([]), use_minc="no", minc=0, use_maxc="no", maxc=255, returnData=True, filterType=None, filterData=None, ): """Create a reconstruction of a sinogram (2D). :param rec_type: Name of the reconstruction algorithm. :type rec_type: :class:`string` :param proj_id: ID of the projector to use. :type proj_id: :class:`int` :param sinogram: Sinogram data or ID. :type sinogram: :class:`numpy.ndarray` or :class:`int` :param iterations: Number of iterations to run. :type iterations: :class:`int` :param use_mask: Whether to use a mask. :type use_mask: ``'yes'`` or ``'no'`` :param mask: Mask data or ID :type mask: :class:`numpy.ndarray` or :class:`int` :param use_minc: Whether to force a minimum value on the reconstruction pixels. :type use_minc: ``'yes'`` or ``'no'`` :param minc: Minimum value to use. :type minc: :class:`float` :param use_maxc: Whether to force a maximum value on the reconstruction pixels. :type use_maxc: ``'yes'`` or ``'no'`` :param maxc: Maximum value to use. :type maxc: :class:`float` :param returnData: If False, only return the ID of the reconstruction. :type returnData: :class:`bool` :param filterType: Which type of filter to use for filter-based methods. :type filterType: :class:`string` :param filterData: Optional filter data for filter-based methods. :type filterData: :class:`numpy.ndarray` :returns: :class:`int` or (:class:`int`, :class:`numpy.ndarray`) -- If ``returnData=False``, returns the ID of the reconstruction. Otherwise, returns a tuple containing the ID of the reconstruction and reconstruction itself, in that order. """ proj_geom = projector.projection_geometry(proj_id) if isinstance(sinogram, np.ndarray): sino_id = data2d.create("-sino", proj_geom, sinogram) else: sino_id = sinogram vol_geom = projector.volume_geometry(proj_id) recon_id = data2d.create("-vol", vol_geom, 0) cfg = astra_dict(rec_type) if not "CUDA" in rec_type: cfg["ProjectorId"] = proj_id cfg["ProjectionDataId"] = sino_id cfg["ReconstructionDataId"] = recon_id cfg["options"] = {} if use_mask == "yes": if isinstance(mask, np.ndarray): mask_id = data2d.create("-vol", vol_geom, mask) else: mask_id = mask cfg["options"]["ReconstructionMaskId"] = mask_id if not filterType == None: cfg["FilterType"] = filterType if not filterData == None: if isinstance(filterData, np.ndarray): nexpow = int(pow(2, math.ceil(math.log(2 * proj_geom["DetectorCount"], 2)))) filtSize = nexpow / 2 + 1 filt_proj_geom = create_proj_geom("parallel", 1.0, filtSize, proj_geom["ProjectionAngles"]) filt_id = data2d.create("-sino", filt_proj_geom, filterData) else: filt_id = filterData cfg["FilterSinogramId"] = filt_id cfg["options"]["UseMinConstraint"] = use_minc cfg["options"]["MinConstraintValue"] = minc cfg["options"]["UseMaxConstraint"] = use_maxc cfg["options"]["MaxConstraintValue"] = maxc cfg["options"]["ProjectionOrder"] = "random" alg_id = algorithm.create(cfg) algorithm.run(alg_id, iterations) algorithm.delete(alg_id) if isinstance(sinogram, np.ndarray): data2d.delete(sino_id) if use_mask == "yes" and isinstance(mask, np.ndarray): data2d.delete(mask_id) if not filterData == None: if isinstance(filterData, np.ndarray): data2d.delete(filt_id) if returnData: return recon_id, data2d.get(recon_id) else: return recon_id
import argparse import os import scraper import filter import algorithm parser = argparse.ArgumentParser() parser.add_argument("-u", "--url", help="Start URL") parser.add_argument("-t", "--target", help="Target URL") parser.add_argument("-l", "--limit", type=int, help="Layer limit") args = parser.parse_args() url = args.url # make a check for empty and url format? target = args.target limit = args.limit links = [] filter.get_links(scraper.grab_site(url), links) algorithm.run(links, target, 0, limit)