eyurtsev / fcsparser

A python parser for reading fcs files supporting FCS 2.0, 3.0, 3.1
MIT License
73 stars 43 forks source link

Loading data from CyFlow Cube 8 #14

Closed MattLodge closed 6 years ago

MattLodge commented 6 years ago

Hi,

I've been trying to use this module with some data generated using the CyFlow Cube 8. When I attempt to read the data I get a error as follows: ValueError: item #0 of names is of type bytes and not string

this traces to line 375 in api.py: data.dtype.names = tuple([name.encode('ascii', errors='replace') for name in names])

If I remove the encoding, everything seems to work as expected. Is this a real issue or am I loading my files incorrectly?

eyurtsev commented 6 years ago

Could you email me the fcs file that generates the problem? eyurtsev at gmail dot com

eyurtsev commented 6 years ago

(or add as an attachment to this thread)

MattLodge commented 6 years ago

Here you go Partec - Background 1.zip

eyurtsev commented 6 years ago

grazie will try to take a look this weekend

eyurtsev commented 6 years ago

Fixed the bug... I added your fcs file to the test suit -- I hope that's okay.

The fix is available on master now -- I'll try to release a version on pypi within a week or so


Also I noticed that the FCS file that uses unsigned ints for some of the datatypes, so be very careful when working with the data and perhaps force convert everything into float32.

In fact, I need to think about the consequences of this for a bit, but will probably turn on automatic conversion to float32.

from fcsparser import parse p = './data/cyflow_cube_8.fcs' df = parse(p)[1]

print(df.dtypes)

FSC uint16 SSC uint16 FL1 uint16 FL2 uint16 FL3 uint16 FL4 uint16 FL5 uint16 FL6 uint16 TIME uint32 DOUBLET uint8 dtype: object

df2 = df.astype('float32') # <-- This will be safer to work with

eyurtsev commented 6 years ago

fcsparser==0.2.0 has been released on pypi with a fix for you issue. Please take it for a spin when you have time. :)