Skip to content

Commit

Permalink
finish javadoc for the class
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 12, 2023
1 parent 0d62b24 commit 7c2a684
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,47 @@
import java.io.FileNotFoundException;
import java.io.IOException;

import io.bioimage.modelrunner.tensor.Tensor;
import io.bioimage.modelrunner.numpy.DecodeNumpy;

import net.imglib2.RandomAccessibleInterval;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;

/**
* Class that maps {@link Tensor} objects to the shared memory for interprocessing communication
* TODO get rid of this class in favour of shared memory IPC
* Class that maps {@link Tensor} objects to a temporal file for inter-processing communication
*
* @author Carlos Garcia Lopez de Haro
*/
public final class SharedMemoryFile
{
/**
* Create a .npy Numpy file from a {@link RandomAccessibleInterval}
* @param <T>
* the ImgLib2 data type of the {@link RandomAccessibleInterval}
* @param fileDir
* file path to the .npy file that is going to be created
* @param rai
* the {@link RandomAccessibleInterval} of interest
* @throws FileNotFoundException if the parent directory where the file wants to be created does not exist
* @throws IOException if there is any error creating the file
*/
public static <T extends RealType<T> & NativeType<T>>
void buildFileFromRai(String fileDir, RandomAccessibleInterval<T> rai) throws FileNotFoundException, IOException {
DecodeNumpy.writeRaiToNpyFile(fileDir, rai);
}

/**
* Read a {@link RandomAccessibleInterval} from a .npy Numpy file created to share between processes
* @param <T>
* the ImgLib2 data type of the {@link RandomAccessibleInterval}
* @param fileName
* name of the .npy file that contains a {@link RandomAccessibleInterval}
* @return a {@link RandomAccessibleInterval}
* @throws FileNotFoundException if the file is not found
* @throws IOException if there is any error reading the file
*/
public static <T extends RealType<T> & NativeType<T>>
RandomAccessibleInterval<T> buildRaiFromFile(String fileName) throws FileNotFoundException, IOException {
return DecodeNumpy.retrieveImgLib2FromNpy(fileName);
Expand Down

0 comments on commit 7c2a684

Please sign in to comment.