How to use the neuroglancer.ViewerState.interpolate function in neuroglancer

To help you get started, we’ve selected a few neuroglancer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / neuroglancer / python / neuroglancer / tool / video_tool.py View on Github external
t = frame_i / num_frames
                if frame_number >= end_frame:
                    return

                if frame_number < start_frame:
                    frame_number += 1
                    continue

                path = saver.get_path(frame_number)

                if args.resume and os.path.exists(path):
                    frame_number += 1
                    with lock:
                        num_frames_written[0] += 1
                else:
                    cur_state = neuroglancer.ViewerState.interpolate(a, b, t)
                    states_to_capture.append((frame_number, i + t, cur_state))
                    frame_number += 1
        for frame_number, t, cur_state in states_to_capture:
            prefetch_states = [
                x[2]
                for x in states_to_capture[frame_number + 1:frame_number + 1 + num_prefetch_frames]
            ]
            viewer.set_state(cur_state)
            if num_prefetch_frames > 0:
                with viewer.config_state.txn() as s:
                    del s.prefetch[:]
                    for i, state in enumerate(prefetch_states[1:]):
                        s.prefetch.append(
                            neuroglancer.PrefetchState(state=state, priority=num_prefetch_frames - i))
            frame_number, path = saver.capture(frame_number)
            with lock:
github google / neuroglancer / python / neuroglancer / tool / video_tool.py View on Github external
def get_frame(self, frame_i):
        start_keypoint = self.get_keypoint_from_frame(frame_i)
        a = self.keypoints[start_keypoint]['state']
        if start_keypoint == len(self.keypoints) - 1:
            return a
        else:
            end_keypoint = start_keypoint + 1
            b = self.keypoints[end_keypoint]['state']
            start_frame = self.keypoint_start_frame[start_keypoint]
            end_frame = self.keypoint_end_frame[start_keypoint]
            t = (frame_i - start_frame) / (end_frame - start_frame)
            return neuroglancer.ViewerState.interpolate(a, b, t)