Ejemplo n.º 1
0
        public static void segmentation_pipeline(out List <vtkImageData> outputs, Rendering.renderPipeLine volume, int[] batch_d, int[] extent, int[] axes, string wpath, int bs = 2)
        {
            //Outputs
            outputs = new List <vtkImageData>();
            //Get input dimensions
            int[] dims = volume.getDims();

            // Initialize UNet
            UNet model = new UNet();

            try
            {
                model.Initialize(24, batch_d, wpath, false);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Model not found");

                return;
            }

            for (int k = 0; k < axes.Length; k++)
            {
                outputs.Add(vtkImageData.New());
            }

            //Segment BCI from axis
            for (int k = 0; k < axes.Length; k++)
            {
                //Inference
                IList <IList <float> > result = segment_sample(volume, model, extent, axes[k], bs, (float)108.58790588378906, (float)47.622276306152344);
                //Copy result to vtkImagedata
                vtkImageData _tmp = IO.inference_to_vtk(result, new int[] { dims[1] + 1, dims[3] + 1, dims[5] + 1 }, extent, axes[k]);

                outputs.ElementAt(k).DeepCopy(_tmp);
                _tmp.Dispose();
                result = null;
            }
            model.Dispose();
        }
Ejemplo n.º 2
0
        public static void segmentation_pipeline(out List <vtkImageData> outputs, Rendering.renderPipeLine volume, int[] batch_d, int[] extent, int[] axes, int bs = 2)
        {
            //Outputs
            outputs = new List <vtkImageData>();
            //Get input dimensions
            int[] dims = volume.getDims();

            //Initialize unet
            string wpath = "Z:\\Tuomas\\UNetE3BN.h5";

            UNet model = new UNet();

            model.Initialize(24, batch_d, wpath, false);

            //Segment BCI from axis
            foreach (int axis in axes)
            {
                IList <IList <float> > result = segment_sample(volume, model, extent, axis, bs, (float)113.05652141, (float)39.87462853);
                //Convert back to vtkimage data
                vtkImageData tmp = IO.inference_to_vtk(result, new int[] { dims[1] + 1, dims[3] + 1, dims[5] + 1 }, extent, axis);
                outputs.Add(tmp);
            }
        }