How to use Raw method in a macro with directory and file arguments?

raw
Tags: #<Tag:0x00007fd540893ab0>

#1

Dear all,

Since few days I am seraching to solve my problem without success. I explain me :

I must find max dynamic on each pixel in an image sequence. Initially, I converted the raw data in avi file and made my treatment. Then I automized treatment with folder scanning, when file finidhed by “avi”, I open it and do treatment. With this I can perform treatment of all file in a folder without human intervention. :smile:

Now I can open raw data by using the Raw method but I didn’t find how to open a specific file, when I use the Raw method in the macro it open me Dialogbox whereas I would specified path arguments in the method to open directly the right file.

Do you know if it is possible ? or how to do in an other way ?

Up to know I use the “Raw_file_opener” to open several raw file and then I scan the file to perform treatement on the selected file but I am limiting by the available memory and can not scan all the folder in one run and need human intervention to perform data treatment. :rage:

I give you my macro skeleton below :

macro RechercheDyn {

close("*")

//1

input = getDirectory(“Dossier de donnée”);
output = input + “Resultats\”;
File.makeDirectory(output);

/sélection des dimensions de carto par boite de dialogue/
Dialog.create(“format composant ?”);
Dialog.addNumber(“largeur :”, 384);
Dialog.addNumber(“hauteur :”, 288);
Dialog.show();
nbcol=Dialog.getNumber();
nblig=Dialog.getNumber();

run(“Raw File Opener”, “image=[16-bit Unsigned] width=nbcol height=nblig offset=0 number=3000 gap=0 little-endian”);

//2 traitement des fichiers .bin : traitement successif par balayage du dossier des fichiers ouverts

list = getFileList(input);
for (i = 0; i < list.length; i++) {

	
	if(endsWith(list[i], ".bin")) {
		recherchePbin(input, list[i], output);
				}
	if(endsWith(list[i], ".avi"))  {
		recherchePavi(input, list[i], output);
				}

}

close("*");

//3 fichier bin

function recherchePbin(input, file, output) {

if(isOpen(file))	{

	selectWindow(file);	
		run("Z Project...", "projection=[Min Intensity]");
		selectWindow(file);
		run("Z Project...", "projection=[Max Intensity]");
		imageCalculator("Subtract create", "MAX_" + file,"MIN_" + file);
		
	selectWindow("Result of MAX_" + file);
		run("Enhance Contrast", "saturated=0.5");
		run("8-bit");
		run("Invert");
		run("Flip Vertically");
		saveAs("JPG", output + "rechercheParticule_" + file );
	close();
		close("*" + file);
	}
else		{

	return;
		}
}

//3 fichier avi

function recherchePavi(input, file, output) {
		
	open(input + file);
		run("Z Project...", "projection=[Min Intensity]");
	selectWindow(file);
		run("Z Project...", "projection=[Max Intensity]");
		imageCalculator("Subtract create", "MAX_" + file,"MIN_" + file);
		
	selectWindow("Result of MAX_" + file);
		run("Invert");
		run("Enhance Contrast", "saturated=0.5");
		run("Flip Vertically");
		saveAs("JPG", output + "rechercheParticule_" + file );
	close();
		close("*" + file);
}

}

Thanks for your help.

Romain


#2

Hi Romain,

The Raw file opener accepts file paths, from the macro recorder:

run("Raw...", "open=/home/sverre/Time-lapses/Timepoint034.tif image=[16-bit Unsigned] width=512 height=512 little-endian");

Or to open all files in a directory (see “open” at the end):

run("Raw...", "open=/home/sverre/Time-lapses/Timepoint034.tif image=[16-bit Unsigned] width=512 height=512 little-endian open");

Hope this helps. And in the future, please share a minimal example of your macro that explains the problem you are facing, rather than all the code. This makes it easier for people to understand your issue. And please keep the code in english, unless you are 120% sure that the code will never be read by someone who doesn’t speak your language.


#3

Thanks a lot Sverre !! :slight_smile:

I tried some way with open in argument but not with “=”. Now it works well, I do not use the “open all files” option since it could saturate memory, I will perform analysis on about 100 Gb of Raw files. I tried with “virtual option” but in this case I must give the exact number of frame whereas I fixed at 3000 since files conatines between 100 and 3000 frames. It is a little bit longer but I can launch it in invisible time.

Thus here is my new command :

run(“Raw…”, “open=[path] image=[16-bit Unsigned] width=nbcol height=nblig offset=0 number=3000 gap=0 little-endian”);

I will take your advices in account to update my macro all in english and will try to be clearer in my issue description for future.

Kind regards and have a good day !