⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rest_sliceviewer.m

📁 While resting-state fMRI is drawing more and more attention, there has not been a software for its d
💻 M
📖 第 1 页 / 共 5 页
字号:
	while ~isempty(find(theZSeries<=0)),
		theZSeries(find(theZSeries<=0)) = theZSeries(find(theZSeries<=0)) +nDim3;
	end
	while ~isempty(find(theZSeries>nDim3)),
		theZSeries(find(theZSeries>nDim3)) = theZSeries(find(theZSeries>nDim3)) -nDim3;
	end
	
	theTransverseImg = zeros(nDim2 * AConfig.Montage.Down, nDim1 *AConfig.Montage.Across);
	for theRow=AConfig.Montage.Down:-1:1,
		for theCol=1:AConfig.Montage.Across,
			%I don't draw the last image because it is used to indicate the positions				
			theZIndex = theZSeries((theRow-1)*AConfig.Montage.Across +theCol);
			theTransverseImg((theRow-1)*nDim2 +(1:nDim2), (theCol-1)*nDim1+(1:nDim1)) =GetGrayImage('Transverse', AConfig.Volume, theZIndex);
			%Write the Z Coordinates to the left-down corner
			%I have to move this code to the end of Setting Axis by using TEXT function
			
			%Save the Center image's Row and Col for CrossHair-line displaying
			if theZIndex==theCenterZ,
				theCenterZ_Row =theRow;
				theCenterZ_Col =theCol;
			end
		end
	end		

	%Save View Series
	AConfig.ViewSeries = theZSeries;
	%Auto balance	
	theTransverseImg =SaturateContrast(theTransverseImg, AConfig.Contrast.SatMin, AConfig.Contrast.SatMax);
	
	%Calculate the Result Image after Magnifying
	theMagnifyCoefficient =GetMagnifyCoefficient(AConfig);
	if license('test','image_toolbox')==1 && theMagnifyCoefficient~=1, 		
		theTransverseImg=imresize(theTransverseImg, theMagnifyCoefficient);
	end
	
	% Revise the Axes position to make it comfort to Magnify
	theFramePosParamSet =get(AConfig.hFrameSetPos, 'Position');
	theLeft 	=theFramePosParamSet(1) +theFramePosParamSet(3) +5;
	theBottom 	=10; %theFramePosParamSet(2);	
	thePosTransverse 	=[theLeft, theBottom, size(theTransverseImg,2), size(theTransverseImg,1)];
	
	%Map images to true color	
	theTransverseImg =repmat(theTransverseImg, [1 1 3]);
	
	%Add overlay
	if SeeOverlay(AConfig),
		theTransverseImg =AddOverlaySeries(AConfig, theTransverseImg);
	end
	
	% Show Images
	%Sagittal		
	set(AConfig.hAxesSagittal, 'Visible','off');
	set(AConfig.hImageSagittal,'Visible','off');
	set(AConfig.hXLineSagittal, 'Visible','off');
	set(AConfig.hYLineSagittal, 'Visible','off');	
	%Coronal		 
	set(AConfig.hAxesCoronal, 'Visible','off');
	set(AConfig.hImageCoronal,'Visible','off');
	set(AConfig.hXLineCoronal, 'Visible','off');
	set(AConfig.hYLineCoronal, 'Visible','off');	
	
	%Transverse
	%theTransverseImg =repmat(theTransverseImg, [1, 1, 3])/AConfig.Contrast.GrayDepth; % For true color display
	set(AConfig.hImageTransverse, 'CData', (theTransverseImg), 'HitTest', 'off', 'Visible','on');
	%colormap(gray(AConfig.Contrast.GrayDepth));	
	set(AConfig.hAxesTransverse, 'Visible','on', ...
		'XLim', [1 size(theTransverseImg,2)], ...
		'YLim', [1 size(theTransverseImg,1)], ...
		'Position', thePosTransverse);	
	set(AConfig.hXLineTransverse, 'HitTest','off','Visible', IsCrosshairChecked(AConfig), ...		
		'XData', ([1 nDim1] +(theCenterZ_Col-1)*nDim1 )* theMagnifyCoefficient, ...
		'YData', ([1 1]*AConfig.LastPosition(2) + (theCenterZ_Row-1)*nDim2) *theMagnifyCoefficient);%Parallel to X-axis
	set(AConfig.hYLineTransverse, 'HitTest','off','Visible', IsCrosshairChecked(AConfig), ...		
		'XData', ([1 1]*AConfig.LastPosition(1)+(theCenterZ_Col-1)*nDim1) * theMagnifyCoefficient , ...
		'YData', ([1 nDim2]+(theCenterZ_Row-1)*nDim2)* theMagnifyCoefficient );%Parallel to Y-axis
	
	
	%Clear Text labels first
	ClearTextLabels(AConfig);
	
	%Write text label to indicate the Z value
	if AConfig.Montage.WantLabel,
		for theRow=AConfig.Montage.Down:-1:1,
			for theCol=1:AConfig.Montage.Across,
				%I don't draw the last image because it is used to indicate the positions				
				theZIndex = theZSeries((theRow-1)*AConfig.Montage.Across +theCol);
				theZIndex = theZIndex -AConfig.Origin(3);
												
				%Transform to Physical distance 20071102
				theZIndex = AConfig.VoxelSize(3) *theZIndex;
						
				
				theY =(theRow)*nDim2* theMagnifyCoefficient;
				theX =(theCol-1)*nDim1* theMagnifyCoefficient;
				
				text( theX,theY,sprintf('%+gmm',theZIndex), 'Parent', AConfig.hAxesTransverse, 'Color', AConfig.Overlay.LabelColor, 'HitTest', 'off', 'VerticalAlignment', 'top', 'Units', 'pixels');			
			end
		end	
	end
	
	Result =AConfig;
	
function Result =SetView_Sagittal(AConfig)
	[nDim1 nDim2 nDim3] =size(AConfig.Volume);
	theCenterX =AConfig.LastPosition(1);
	theCount   =AConfig.Montage.Across *AConfig.Montage.Down ;
	
	theXSeries =theCenterX -([floor(theCount/2) : -1 :ceil(-theCount/2)]) *AConfig.Montage.Spacing;	
	while ~isempty(find(theXSeries<=0)),
		theXSeries(find(theXSeries<=0)) = theXSeries(find(theXSeries<=0)) +nDim1;
	end
	while ~isempty(find(theXSeries>nDim1)),
		theXSeries(find(theXSeries>nDim1)) = theXSeries(find(theXSeries>nDim1)) -nDim1;
	end
	
	theSagittalImg = zeros(nDim3 * AConfig.Montage.Down, nDim2 *AConfig.Montage.Across);
	for theRow=AConfig.Montage.Down:-1:1,
		for theCol=1:AConfig.Montage.Across,
			%I don't draw the last image because it is used to indicate the positions				
			theXIndex = theXSeries((theRow-1)*AConfig.Montage.Across +theCol);
			theSagittalImg((theRow-1)*nDim3 +(1:nDim3), (theCol-1)*nDim2+(1:nDim2)) =GetGrayImage('Sagittal', AConfig.Volume, theXIndex);
			%Write the X Coordinates to the left-down corner
			%I have to move this code to the end of Setting Axis by using TEXT function
			
			%Save the Center image's Row and Col for CrossHair-line displaying
			if theXIndex==theCenterX,
				theCenterX_Row =theRow;
				theCenterX_Col =theCol;
			end
		end
	end		
	%Save View Series
	AConfig.ViewSeries = theXSeries;
	%Auto balance	
	theSagittalImg =SaturateContrast(theSagittalImg, AConfig.Contrast.SatMin, AConfig.Contrast.SatMax);
	
	%Calculate the Result Image after Magnifying
	theMagnifyCoefficient =GetMagnifyCoefficient(AConfig);
	if license('test','image_toolbox')==1 && theMagnifyCoefficient~=1, 		
		theSagittalImg=imresize(theSagittalImg, theMagnifyCoefficient);
	end
	
	% Revise the Axes position to make it comfort to Magnify
	theFramePosParamSet =get(AConfig.hFrameSetPos, 'Position');
	theLeft 	=theFramePosParamSet(1) +theFramePosParamSet(3) +5;
	theBottom 	=10; %theFramePosParamSet(2);	
	thePosSagittal 	=[theLeft, theBottom, size(theSagittalImg,2), size(theSagittalImg,1)];
	
	%Map images to true color	 
	theSagittalImg =repmat(theSagittalImg, [1 1 3]);
	
	%Add overlay
	if SeeOverlay(AConfig),
		theSagittalImg =AddOverlaySeries(AConfig, theSagittalImg);	
	end
	
	% Show Images
	%Transverse			
	set(AConfig.hAxesTransverse, 'Visible','off');
	set(AConfig.hImageTransverse,'Visible','off');
	set(AConfig.hXLineTransverse, 'Visible','off');
	set(AConfig.hYLineTransverse, 'Visible','off');
	%Coronal		 
	set(AConfig.hAxesCoronal, 'Visible','off');
	set(AConfig.hImageCoronal,'Visible','off');
	set(AConfig.hXLineCoronal, 'Visible','off');
	set(AConfig.hYLineCoronal, 'Visible','off');	
	
	%Transverse
	%theTransverseImg =repmat(theTransverseImg, [1, 1, 3])/AConfig.Contrast.GrayDepth; % For true color display
	set(AConfig.hImageSagittal, 'CData', (theSagittalImg), 'HitTest', 'off', 'Visible','on');
	%colormap(gray(AConfig.Contrast.GrayDepth));	
	set(AConfig.hAxesSagittal, 'Visible','on', ...
		'XLim', [1 size(theSagittalImg,2)], ...
		'YLim', [1 size(theSagittalImg,1)], ...
		'Position', thePosSagittal);	
	set(AConfig.hXLineSagittal, 'HitTest','off','Visible', IsCrosshairChecked(AConfig), ...		
		'XData', ([1 nDim2] +(theCenterX_Col-1)*nDim2 )* theMagnifyCoefficient, ...
		'YData', ([1 1]*AConfig.LastPosition(3) + (theCenterX_Row-1)*nDim3) *theMagnifyCoefficient);%Parallel to X-axis
	set(AConfig.hYLineSagittal, 'HitTest','off','Visible', IsCrosshairChecked(AConfig), ...		
		'XData', ([1 1]*AConfig.LastPosition(2)+(theCenterX_Col-1)*nDim2) * theMagnifyCoefficient , ...
		'YData', ([1 nDim3]+(theCenterX_Row-1)*nDim3)* theMagnifyCoefficient );%Parallel to Y-axis
		
	%Clear Text labels first
	ClearTextLabels(AConfig);	
	%Write text label to indicate the Z value
	if AConfig.Montage.WantLabel,
		for theRow=AConfig.Montage.Down:-1:1,
			for theCol=1:AConfig.Montage.Across,							
				theXIndex = theXSeries((theRow-1)*AConfig.Montage.Across +theCol);
				theXIndex = theXIndex -AConfig.Origin(1);
				
				%Transform to Physical distance 20071102
				theXIndex = AConfig.VoxelSize(1) *theXIndex;
				%Dawnsong 20071102 Revise to make sure the left image/Right brain is +
				theXIndex =(-1) *theXIndex;
							
				
				theY =(theRow)*nDim3* theMagnifyCoefficient;
				theX =(theCol-1)*nDim2* theMagnifyCoefficient;
				text( theX,theY,sprintf('%+gmm',theXIndex), 'Parent', AConfig.hAxesSagittal, 'Color', AConfig.Overlay.LabelColor, 'HitTest', 'off', 'VerticalAlignment', 'top', 'Units', 'pixels');			
			end
		end	
	end
			
	Result =AConfig;
	
function Result =SetView_Coronal(AConfig)
	[nDim1 nDim2 nDim3] =size(AConfig.Volume);
	theCenterY =AConfig.LastPosition(2);
	theCount   =AConfig.Montage.Across *AConfig.Montage.Down ;
	
	theYSeries =theCenterY -([floor(theCount/2) : -1 :ceil(-theCount/2)]) *AConfig.Montage.Spacing;	
	while ~isempty(find(theYSeries<=0)),
		theYSeries(find(theYSeries<=0)) = theYSeries(find(theYSeries<=0)) +nDim2;
	end
	while ~isempty(find(theYSeries>nDim2)),
		theYSeries(find(theYSeries>nDim2)) = theYSeries(find(theYSeries>nDim2)) -nDim2;
	end
	
	theCoronalImg = zeros(nDim3 * AConfig.Montage.Down, nDim1 *AConfig.Montage.Across);
	for theRow=AConfig.Montage.Down:-1:1,
		for theCol=1:AConfig.Montage.Across,
			%I don't draw the last image because it is used to indicate the positions				
			theYIndex = theYSeries((theRow-1)*AConfig.Montage.Across +theCol);
			theCoronalImg((theRow-1)*nDim3 +(1:nDim3), (theCol-1)*nDim1+(1:nDim1)) =GetGrayImage('Coronal', AConfig.Volume, theYIndex);
			%Write the Z Coordinates to the left-down corner
			%I have to move this code to the end of Setting Axis by using TEXT function
			
			%Save the Center image's Row and Col for CrossHair-line displaying
			if theYIndex==theCenterY,
				theCenterY_Row =theRow;
				theCenterY_Col =theCol;
			end
		end
	end			
	%Save View Series
	AConfig.ViewSeries = theYSeries;
	%Auto balance
	theCoronalImg =SaturateContrast(theCoronalImg, AConfig.Contrast.SatMin, AConfig.Contrast.SatMax);
	
	%Calculate the Result Image after Magnifying
	theMagnifyCoefficient =GetMagnifyCoefficient(AConfig);
	if license('test','image_toolbox')==1 && theMagnifyCoefficient~=1, 		
		theCoronalImg=imresize(theCoronalImg, theMagnifyCoefficient);
	end
	
	% Revise the Axes position to make it comfort to Magnify
	theFramePosParamSet =get(AConfig.hFrameSetPos, 'Position');
	theLeft 	=theFramePosParamSet(1) +theFramePosParamSet(3) +5;
	theBottom 	=10; %theFramePosParamSet(2);	
	thePosCoronal 	=[theLeft, theBottom, size(theCoronalImg,2), size(theCoronalImg,1)];
	
	%Map images to true color	
	theCoronalImg =repmat(theCoronalImg, [1 1 3]);
	
	%Add overlay
	if SeeOverlay(AConfig),
		theCoronalImg =AddOverlaySeries(AConfig, theCoronalImg);	
	end
	
	% Show Images
	%Transverse			
	set(AConfig.hAxesTransverse, 'Visible','off');
	set(AConfig.hImageTransverse,'Visible','off');
	set(AConfig.hXLineTransverse, 'Visible','off');
	set(AConfig.hYLineTransverse, 'Visible','off');
	%Sagittal
	set(AConfig.hAxesSagittal, 'Visible','off');
	set(AConfig.hImageSagittal,'Visible','off');
	set(AConfig.hXLineSagittal, 'Visible','off');
	set(AConfig.hYLineSagittal, 'Visible','off');
		
	%Transverse
	%theTransverseImg =repmat(theTransverseImg, [1, 1, 3])/AConfig.Contrast.GrayDepth; % For true color display
	set(AConfig.hImageCoronal, 'CData', (theCoronalImg), 'HitTest', 'off', 'Visible','on');
	%colormap(gray(AConfig.Contrast.GrayDepth));	
	set(AConfig.hAxesCoronal, 'Visible','on', ...
		'XLim', [1 size(theCoronalImg,2)], ...
		'YLim', [1 size(theCoronalImg,1)], ...
		'Position', thePosCoronal);	
	
	set(AConfig.hXLineCoronal, 'HitTest','off','Visible', IsCrosshairChecked(AConfig), ...		
		'XData', ([1 nDim1] +(theCenterY_Col-1)*nDim1 )* theMagnifyCoefficient, ...
		'YData', ([1 1]*AConfig.LastPosition(3) 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -