Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata needs to be read alongside data #3

Open
cameronsamuell opened this issue May 24, 2017 · 1 comment
Open

metadata needs to be read alongside data #3

cameronsamuell opened this issue May 24, 2017 · 1 comment

Comments

@cameronsamuell
Copy link

Hi, This is a fantastic utility.

Maybe i've missed an option someplace, but I don't think you're accounting for the possibility of metadata being present. In this case, the times and frame numbers will be present after the data and so become convoluted with the pixel values in your implementation. Easy enough fix, you just need to do a check for the values and dtypes in your MetaBlock and then read them in during _read_data. Alternatively compare the difference between the frame size and stride size to find the number of additional bytes to be read for each frame.

For example, the following would work for 3 pieces of metadata.

def _read_data(self, file):
        file.seek(4100)
        
        data = [[0 for _ in range(self.nroi)] for _ in range(self.nframes)]
        metadata = []
        for frame in range(0, self.nframes):
            for region in range(0, self.nroi):
                if self.nroi > 1:
                    data_xdim = len(self.xcoord[region])
                    data_ydim = len(self.ycoord[region])
                else:
                    data_xdim = np.asarray(self.xdim[region], np.uint32)
                    data_ydim = np.asarray(self.ydim[region], np.uint32)
                data[frame][region] = np.fromfile(file, self.dtype, data_xdim * data_ydim).reshape(data_ydim, data_xdim)
            metadata.append(np.fromfile(file, np.dtype('Int64'),3))
            
        return data, metadata

Cheers,
Cam

@ashirsch
Copy link
Owner

Thanks for your interest in the project, and apologies for the delay! I've been away from the lab for the summer and don't have access to LightField, meaning that the above pull request is not currently tested on actual spe files. I'm working on getting my hands on some test files, but in the meantime please checkout the new branch and see what you think. Best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants