コード例 #1
0
            print("WARNING: no data in {}.img.txt, please input:".format(
                basename))
            nscanlines = int(input("\tnscanlines (usually 127) "))
            npoints = int(input("\tnpoints (usually 1020) "))
            junk = int(input("\tjunk (usually 36, or 1020 - 984) "))

        # TODO use metadata instead of hard-coded values
        header = Header()
        header.w = nscanlines  # input image width
        header.h = npoints - junk  # input image height, trimmed
        header.sf = 4000000  # magic number, sorry!
        probe = Probe()
        probe.radius = 10000  # based on '10' in transducer model number
        probe.numElements = 128  # based on '128' in transducer model number
        probe.pitch = 185  # based on Ultrasonix C9-5/10 transducer
        conv = Converter(header, probe)

    rdr = RawReader(rf, nscanlines=nscanlines, npoints=npoints)

    # define "support" file names based on .raw
    wav = os.path.join(parent, str(basename + ".ch1.wav"))
    sync = os.path.join(parent, str(basename + '.sync.txt'))
    idx_txt = os.path.join(parent, str(basename + ".idx.txt"))

    # make destination and copy "support" files for parent file
    copy_dir = os.path.join(output_dir, basename)

    os.mkdir(copy_dir)
    shutil.copy(wav, copy_dir)
    shutil.copy(idx_txt, copy_dir)
    shutil.copy(stimfile, copy_dir)
コード例 #2
0
        pca_data = data[mask]
        pca_md = md[mask]
        pca_md = pca_md.reset_index(drop=True)

        # define Converter parameters from first acq for first subj
        if conv is None:
            print("Defining Converter ...")
            header = Header()
            header.w = pca_data[0].shape[1]  # input image width
            header.h = pca_data[0].shape[0]  # input image height, trimmed
            header.sf = 4000000  # magic number, sorry!
            probe = Probe()
            probe.radius = 10000  # based on '10' in transducer model number
            probe.numElements = 128  # based on '128' in transducer model number
            probe.pitch = 185  # based on Ultrasonix C9-5/10 transducer
            conv = Converter(header, probe)

        print("Defining region of interest ...")

        # get mean frame and apply mask
        mean_frame = pca_data.mean(axis=0)
        conv_mean = np.flipud(conv.convert(np.flipud(mean_frame)))
        plt.title("Mean frame, Spkr {:}".format(subject))
        plt.imshow(conv_mean, cmap="Greys_r")
        file_ending_mean = "subj{:}_mean.pdf".format(subject)
        savepath_mean = os.path.join(root, d, file_ending_mean)
        plt.savefig(savepath_mean)
        roi_upper = 600
        roi_lower = 300
        roi_left = 20
        roi_right = 100
コード例 #3
0
 
     class Probe(object):
         def __init__(self):
             pass
 
     header = Header()
     print(header)
 # visualize components on (approximately) converted fan, if desired
     header.w = 127          # input image width
     header.h = 1020 #255          # input image height
     header.sf = 4000000     # for ultrasonix this is the vec-freq value
     probe = Probe()
     probe.radius = 10000    # based on '10' in transducer model number
     probe.numElements = 128 # based on '128' in transducer model number
     probe.pitch = 185 #205  # guess based on Ultrasonix C9-5/10 transducer
     c = Converter(header, probe)
 
     image_shape = (1020,127)#(255,127)
     rdr = RawReader(rf, nscanlines=nscanlines, npoints = npoints)
     print(rf)
     for f in np.arange(0,(last_idx+1)):
         d = rdr.get_frame(f).reshape(image_shape)
         mag = np.max(d) - np.min(d)
         d = (d-np.min(d))/mag*255
         pcn = np.flipud(c.as_bmp(np.flipud(d)))
         #pcn = c.as_bmp(d)
         plt.title("Frame{:}, {:}".format((f+1),stim))
         plt.imshow(pcn, cmap="Greys_r")
         file_ending = "subj{:}-{:}-{:}.png".format(subject, stim,(f))
         ultradir = os.path.join(os.path.basename(barename),file_ending)
         savepath = os.path.join(expdir,ultradir)