예제 #1
0
def test_rotation(subject, subjects_file):
    subject = int(subject)
    import pickle
    # subjects = pickle.load(open(subjects_file, 'rb'))

    # s2 = subjects._sample_s(10)

    # cr = CameraRotate('.')
    # cr.data

    # subjects = []
    # i = 0
    # for s in s2.list():
    # s.id = i
    # subjects.append(s)

    # for n in range(6):
    # a = cr.rotate(s.charge, n)
    # subjects.append(Subject(i + n, None, a))

    # i += 6

    cr = CameraRotate('.')
    cr.data

    subject = Subject(0, None, np.array(range(499)))
    _s = [subject]
    for i in range(1, 6):
        a = cr.rotate(subject.charge, i)
        _s.append(Subject(i, None, a))

    Subjects(_s).plot_subjects(w=6)
    plt.show()

    interact(locals())
예제 #2
0
def run(path, components, mle, plot, save, all):
    if len(path) == 0:
        print('No data files provided')
        return

    # swap.config.logger.init()
    subjects = Subjects.from_data(path)
    logger.info('Done loading subjects')

    if mle:
        cluster = Cluster.create(subjects, 'mle')
    if all:
        cluster = Cluster.create(subjects, None)
    else:
        cluster = Cluster.create(subjects, components)
    logger.info('Done creating cluster')

    if plot:
        try:
            cluster.plot()
        except Exception:
            pass

    if save:
        pickle.dump(cluster, open(save, 'wb'))

    interact(locals())
예제 #3
0
def subject_rotation(subject, subjects_file):
    subject = int(subject)
    import pickle
    subjects = pickle.load(open(subjects_file, 'rb'))

    s2 = subjects._sample_s(10)

    cr = CameraRotate('.')
    cr.data

    subjects = []
    i = 0
    for s in s2.list():
        s.id = i
        subjects.append(s)

        for n in range(1, 6):
            a = cr.rotate(s.charge, n)
            subjects.append(Subject(i + n, None, a))

        i += 6

    Subjects(subjects).plot_subjects(w=6)
    plt.show()

    interact(locals())
예제 #4
0
    def subject_images(self, subjects, size=None):
        """
        Get list of scikit-image objects of subject images from panoptes

        subjects: list of subject ids
        size: select random sample from list of subjects
        """
        print(len(subjects), size)
        if size is not None and size < len(subjects):
            subjects = random.sample(subjects, size)
        print(len(subjects))
        subjects = [self.subjects[s] for s in subjects]
        return Subjects(subjects).load_images()
예제 #5
0
    def download_subjects(self, subjects, size=None, prefix='', dir_=None):
        """
        Download subject images from panoptes

        subjects: list of subject ids
        size: select random sample from list of subjects
        """
        print(len(subjects), size)
        if size is not None and size < len(subjects):
            subjects = random.sample(subjects, size)
        print(len(subjects))
        subjects = [self.subjects[s] for s in subjects]
        Subjects(subjects).download_images(prefix, dir_)
예제 #6
0
def visualize(path):
    subjects = Subjects.from_data(path)
    cluster = Cluster.create(subjects)
    cluster.visualize()
예제 #7
0
def save(fname, data):
    subjects = Subjects.from_data(data)
    pickle.dump(subjects, open(fname, 'wb'))
예제 #8
0
 def charge_array(subjects):
     return Subjects(subjects).get_charge_array()