problem deleting channels

Discussions and questions about topics not covered above
Pawel Kusmierek
Major contributor
Posts: 1413
Joined: 02 Jul 2008, 13:23
Software used: Spike2
1401 type: Power1401 mk II
Location: Georgetown University, Washington DC, USA
Contact:

problem deleting channels

Unread postby Pawel Kusmierek » 26 Nov 2019, 21:51

Hi,

It seems that deleting channels from a sampled data file/time view does not work until the file is closed and reopened. Attached is a demo script that samples one waveform channel, attempts to delete it, fails, saves the file, attempts to delete the channel, fails, closes and reopens the file, and finally succeeds with deleting the channel.

The error returned is "The file is being sampled" though it's not anymore.

If done through GUI, there is no Delete channel option in the pop-up menu until the file is reopened.

I can't see any mention of that in help, so is it a bug?

This is in 9.08b.


Code: Select all

var l%[1];
SampleClear(); 'Set standard sampling state
SampleOptimise(0, -1, 9); 'No optimise, set 1401 type, (do first)
SampleUsPerTime(10);
SampleTimePerAdc(50);
SampleSeqCtrl(1, 0); ' Seqencer jump control


SampleWaveform(1, 0,2000); ' chan, port, ideal rate
SampleTitle$(31,"Keyboard");
SampleOptimise(1,1,9,1,50);  'Set optimise mode (do this last)
SampleMode(1); 'Continuous sampling
FileNew(0,1);
SampleStart();
SampleStop();

PrintLog("stopped:\n");
PrintLog(Error$(ChanDelete(1)) + "\n");
PrintLog(ChanList(l%, 1));

FileSaveAs("cdtest.smrx", -1, 1);

PrintLog("saved:\n");
PrintLog(Error$(ChanDelete(1)) + "\n");
PrintLog(ChanList(l%, 1));

FileClose();

FileOpen("cdtest.smrx", 0);

PrintLog("reopened:\n");
PrintLog(Error$(ChanDelete(1)) + "\n");
PrintLog(ChanList(l%, 1));
Paweł Kuśmierek

Spike2 Power 1401 Mk II

User avatar
Tim Bergel
Site Admin
Posts: 2381
Joined: 19 Jun 2008, 14:40
Location: Cambridge, England
Contact:

Re: problem deleting channels

Unread postby Tim Bergel » 28 Nov 2019, 13:44

No, this is entirely intentional, as the sampling system needs the file channels to remain unchanged. Though perhaps it should be possible to delete the channel once the file has been initially saved. I don't think there is a reason for preventing this at this point but there may be something. I will have a peek.
Tim Bergel Cambridge Electronic Design

Pawel Kusmierek
Major contributor
Posts: 1413
Joined: 02 Jul 2008, 13:23
Software used: Spike2
1401 type: Power1401 mk II
Location: Georgetown University, Washington DC, USA
Contact:

Re: problem deleting channels

Unread postby Pawel Kusmierek » 28 Nov 2019, 18:17

Tim Bergel wrote:No, this is entirely intentional, as the sampling system needs the file channels to remain unchanged.


I guess I did not realize that sampling of the same file can be stopped and then started again, because it can, correct?

Maybe I should explain the reason why I've been trying to do that. This is for script-controlled experiments with ADC acquisition, and the user selects via script dialog how many channels will be sampled for the particular experiments.

To ensure that sampling frequencies do not change with changing number of channels, I do not adjust the sampling configuration based on user's choice prior to sampling. Rather, I always sample the maximum allowed number of channels, but between FileNew and SampleStart, the unused channels are hidden and made not written to, to save both screen and disk space. My intention was to delete these empty and unused channels after sampling and before the file is saved. If this is not possible it's not a big deal, I just need to make sure that any postprocessing/analysis detects those empty channels and does not try to process them.
Paweł Kuśmierek

Spike2 Power 1401 Mk II

User avatar
Tim Bergel
Site Admin
Posts: 2381
Joined: 19 Jun 2008, 14:40
Location: Cambridge, England
Contact:

Re: problem deleting channels

Unread postby Tim Bergel » 29 Nov 2019, 13:35

I guess I did not realize that sampling of the same file can be stopped and then started again, because it can, correct?

I don't think so, not once the sampling has actually stopped.

I think that what we have here is a mechanism that prevents sampled channels being deleted during sampling (as that would foul up the sampling system) and this mechanism is not being fully reset at the end of sampling. So the channels remain un-deleteable(?) until the file is actually re-opened offline. This may be intentional, or perhaps its something that was taken care of with the old SMR file system but has been missed with the new SMRX files.

I will discuss this with Greg and decide what to do, but in the meantime I'm afraid that you will have to work around it - maybe just grit your teeth, close the file, re-open it and delete the channels?
Tim Bergel Cambridge Electronic Design

Pawel Kusmierek
Major contributor
Posts: 1413
Joined: 02 Jul 2008, 13:23
Software used: Spike2
1401 type: Power1401 mk II
Location: Georgetown University, Washington DC, USA
Contact:

Re: problem deleting channels

Unread postby Pawel Kusmierek » 29 Nov 2019, 15:12

Tim Bergel wrote:
I guess I did not realize that sampling of the same file can be stopped and then started again, because it can, correct?

I don't think so, not once the sampling has actually stopped.


I thought that was the reason you said thai it should be possible to delete the channel once the file has been initially saved... if sampling of the same file cannot be re-started, I would think that SampleStop() should release channels for deleting.


Tim Bergel wrote:in the meantime I'm afraid that you will have to work around it - maybe just grit your teeth, close the file, re-open it and delete the channels?

No problem at all, they are empty so they take minimal amount of space, and there are ways to check if the channel is empty by the processing routines. Or I can change their titles or something like that.

I just realized, that while I found the issue writing and testing a new script, another script has used this mechanism for many years. Apparently my processing routines for that script were made immune to empty channels... I probably could go over old files and by checking which of those have and which have not hidden empty channels, find out if it ever worked (e.g. with old smr files) and if yes, when the change was made.
Paweł Kuśmierek

Spike2 Power 1401 Mk II

User avatar
Greg Smith
Major contributor
Posts: 1634
Joined: 19 Jun 2008, 12:27
Software used: Spike2 and Signal
1401 type: Many 1401 types
Location: Cambridge, England
Contact:

Re: problem deleting channels

Unread postby Greg Smith » 04 Dec 2019, 12:05

For version 10.01 I have allowed you to delete a channel once sampling has stopped. This seems to be OK, but makes me nervous... It will not recover any disk space already used by the channel.

The only other way around this would be to load the sampling configuration, then use the SampleClear(chan%) command to remove the unwanted channels before creating the data file. Note that this might cause sample rate changes if any of the deleted channels were ADC-based.
Greg Smith Cambridge Electronic Design

Pawel Kusmierek
Major contributor
Posts: 1413
Joined: 02 Jul 2008, 13:23
Software used: Spike2
1401 type: Power1401 mk II
Location: Georgetown University, Washington DC, USA
Contact:

Re: problem deleting channels

Unread postby Pawel Kusmierek » 04 Dec 2019, 13:05

Greg Smith wrote:For version 10.01 I have allowed you to delete a channel once sampling has stopped.

Thank you. I probably won't upgrade to 10 for quite a while, but I'll appreciate it in the future.


Greg Smith wrote:It will not recover any disk space already used by the channel.

Sure. For this I have SampleWrite(0, i% * 2 + 6); before sampling starts.

Greg Smith wrote:Note that this might cause sample rate changes if any of the deleted channels were ADC-based.

And this is the reason I have chose not to use this method.
Paweł Kuśmierek

Spike2 Power 1401 Mk II


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest