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

How to implement bidirectional scanning? #48

Open
hwuscut opened this issue Feb 26, 2019 · 8 comments
Open

How to implement bidirectional scanning? #48

hwuscut opened this issue Feb 26, 2019 · 8 comments

Comments

@hwuscut
Copy link

hwuscut commented Feb 26, 2019

I implement a bidirectional scanning, but the performance is not good. How to improve it? Thanks very much.

@raacampbell
Copy link
Contributor

raacampbell commented Feb 26, 2019

In what sense is performance not good? There is a simple bidi scanner implemented here: DAQ_ToolBox_Scanners/scanAndAcquire_Polished.m

@hwuscut
Copy link
Author

hwuscut commented Feb 26, 2019

@raacampbell Thanks very much for your replay. I use the DAQmx_Scanners/polishedScanner.m.
In the function generateScanWaveforms(obj) part, I modify the xWaveform
xWaveform = repmat(xWaveform, 1, length(yWaveform)/length(xWaveform));
as
num = length(yWaveform)/length(xWaveform);
if mod(obj.imSize,2) == 1
xWaveform_tmp = xWaveform;
xWaveform = [xWaveform fliplr(xWaveform)];
xWaveform = repmat(xWaveform, 1, (num-1)/2);
xWaveform = [xWaveform, xWaveform_tmp];
else
xWaveform = [xWaveform fliplr(xWaveform)];
xWaveform = repmat(xWaveform, 1, num/2);
end

These can generate a bidirectional scanning signal.

In the function readAndDisplayLastFrame(obj,src,evnt) part, I add new codes as

obj.lastFrame = reshape(obj.lastFrame, obj.correctedPointsPerLine, obj.imSize); % The following is added newly.

obj.flipIndex = 2:2:obj.imSize;
obj.lastFrame(:,obj.flipIndex) = flipud(obj.lastFrame(:,obj.flipIndex));

The performance means the image resolution. The resolution is lower than unidirectional scanning method. What is wrong with the modifications?

Thanks for your help.

@hwuscut
Copy link
Author

hwuscut commented Feb 26, 2019

I will carefully read DAQ_ToolBox_Scanners/scanAndAcquire_Polished.m.

@raacampbell
Copy link
Contributor

Looks like you are missing the phase correction when rebuilding the image. You'll see that in the link I sent, above.

@hwuscut
Copy link
Author

hwuscut commented Feb 26, 2019

Sorry to trouble you again. I find the phase correction part now. But how to determine the delayed phase?
%Flip the even rows if data were acquired bidirectionally
im(2:2:end,:) = fliplr(im(2:2:end,:));

		im(1:2:end,:) = circshift(im(1:2:end,:),-bidiPhaseDelay,2);
		im(2:2:end,:) = circshift(im(2:2:end,:), bidiPhaseDelay,2);

		im = fliplr(im); %To keep it in the same orientation as the uni-directional scan

		im = im(:,1+bidiPhaseDelay:end-bidiPhaseDelay); %Trim the turnaround on one edge (BADLY)
		set(h(chan).imAx,'XLim',[1,size(im,2)]);

@raacampbell
Copy link
Contributor

Empirically whilst you image. The image will go from looking crappy to sharp as you change the value.

@hwuscut
Copy link
Author

hwuscut commented Feb 26, 2019

I use DAQ_ToolBox_Scanners/scanAndAcquire_Polished.m to try the bidirectionally scanning. The result is not good as the unidirectional scanning. I modify the codes, the results are not improved. The phase correction is added. The results are still not improved. May be other improvements are needed.

@raacampbell
Copy link
Contributor

The phase correction is pretty sensitive and some scanners need to be run slower. The object-oriented version of the code allows you to change the scan phase whilst it's running, which is much easier to work with. You can run it without the GUI (see help in scanAndAcquire_OO.m). Scan slowly and play with the phase offset in small increments. Then see how much faster you can scan and still have it work well. If you scan too fast uni-directionally (beyond what the control loop can do), then scanners will produce a distorted image but it will look more reasonable than a bidirectional image that is too fast.

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