package io;

import java.io.File;

import ij.IJ;
import ij.ImagePlus;
import io.nii.Nifti_Writer;
import sc.fiji.io.Nrrd_Writer;

public class WritingHelper {

	public static void write( ImagePlus ip, String outputFilePath )
	{
		if( outputFilePath.endsWith( "nii" ))
		{
			File f = new File( outputFilePath );
			Nifti_Writer writer = new Nifti_Writer( true );
			writer.save( ip, f.getParent(), f.getName() );
		}
		else if( outputFilePath.endsWith( "nrrd" ))
		{
			File f = new File( outputFilePath );
			Nrrd_Writer writer = new Nrrd_Writer();
			writer.save( ip, f.getParent(), f.getName() );
		}
		else
		{
			IJ.save( ip, outputFilePath );
		}
			
	}
}

@@ -301,24 +301,128 @@
 FilePath );%0A
+%0A%09%09%09boolean is_displacement = false;%0A%09%09%09if( ip.getDimensions()%5B 2 %5D == 3 )%0A%09%09%09%09is_displacement = true;%0A%0A
 %09%09%09Nifti_Wri
@@ -452,20 +452,31 @@
 Writer( 
-true
+is_displacement
  );%0A%09%09%09w

add check for writing dfields as nii