From P.Nanda at andor.com Wed Jan 16 01:05:48 2013 From: P.Nanda at andor.com (Pariksheet Nanda) Date: Wed, 16 Jan 2013 00:05:48 +0000 Subject: [iQ-users] Need extra dimension and timestamps in duplicate dataset, but iQImage.duplicate() does not allow creating an extra dimension Message-ID: <480E81CC9EFEE24B8A13EA161EBD3114AED3D764@CT-EXCH-01.andortech.net> Hi Patrick, > Creating "ROIs" over a FRAPPA dataset for presentation purposes, by > adding a new channel dimension to write the ROI data. However in > the new dataset the new dimension should also use the timestamps of > the original dataset to be useful in the iQ Analysis window. > 1. Is there a way to copy timestamps of one dataset to another? > 2. Alternatively is there a way to add another dimension to a > duplicated dataset? You can copy the timestamps from your original single-channel dataset to your new image this way: #---------------------------------------------------------------------- from imagedisk import iQImageDisk from numpy import zeros, concatenate ## Get stamps of the original dataset ## stamps = [im.getStamp(i) for i in range(im.nframes())] ## Add channel to the original data and save in the new image ## data = im[:] # only add 1 channel, keeping other dimensions the smae extra_channel_shape = list(data.shape) extra_channel_shape[1] = 1 extra_channel = zeros(extra_channel_shape, dtype=im.dtype) # FIXME: There's an indexing bug in this concatenate statement, where # alternate frames have channel data instead of the frame pair. Fix # may require numpy fancy indexing to fix or using iQImage.slice2index data_with_new_channel = concatenate( (data, extra_channel), axis=1) im2 = id.newImage('extra_channel_image', data_with_new_channel, im.dimNames) ## Write stamps to the new dataset ## for i in im2.slice2index[:,0]: im2.setStamp(i, stamps[i]) #---------------------------------------------------------------------- I'm curious if/how you are able to interleave the channels correctly `data_with_new_channel` in the above script is not indexed properly. Perhaps it would be generally useful to hack the iQImage class in ./PythonEngine/Python/imagedisk/__init__.py to have a "merge datasets" feature, or one could pass an optional "newaxis" argument to iQImage.duplicate() to create a new dimension at the appropriate position. What do you think? Pariksheet [http://www.andor.com/newsletter/footer/sig.jpg] [http://www.andor.com/newsletter/cap.png] -------------- next part -------------- An HTML attachment was scrubbed... URL: