Posted by
Lachlan Whitehead on
Nov 05, 2013; 2:52am
URL: http://imagej.273.s1.nabble.com/simple-path-problem-tp5005447p5005449.html
Hi Rui,
Looking at the code I think you just need to put some " and + characters to build the string correctly. Where you have
directory=inputDir1 + file1 file_names=newlist_{ii}.tif
try
directory="+inputDir1 + file1+" file_names="+newlist+"_{ii}.tif
I haven't run the code as I don't have your directory structure, but I think that should help you out. Incidentally, where you're checking if the filepath is a file or a directory be careful using the "/" character as a checker, it can cause problems on other operating systems (I've struggled with this in the past). Consider changing it to:
if (File.isDirectory(inputDir1+fileList1[k]))
Hope this helps.
-Lachie
----- Original Message -----
From: "thr rui" <
[hidden email]>
To:
[hidden email]
Sent: Tuesday, 5 November, 2013 8:36:24 AM
Subject: simple path problem
Hi,
I feel this must be simple to fix, but i have not been able to find it
anywhere yet for a while.
I have three images (E8_001_01, E8_001_02, E8_001_03) saved in the folder
that same name as the first image ( folder name: E8_001_01) that i would
like to stitch using grid/stitching plugin.
Then i have bunch of folders under the main directory in D drive.
I have recorded macro as below.
run("Grid/Collection stitching", "type=[Grid: snake by rows] order=[Left &
Up] grid_size_x=2 grid_size_y=2 tile_overlap=60 first_file_index_i=1
directory=D:\\Histology_2013\\test13\\dir\\ffcr_8d_026_01_01
file_names=ffcr_8d_026_01_{ii}.tif
output_textfile_name=TileConfiguration.txt fusion_method=[Linear Blending]
regression_threshold=0.80 max/avg_displacement_threshold=2.50
absolute_displacement_threshold=3.50 compute_overlap subpixel_accuracy
computation_parameters=[Save computation time (but use more RAM)]
image_output=[Fuse and display]");
Based on recorded macro, I modified a macro code as below using loop,
however, plugin cannot read the path of directory and file name.
inputDir1 = getDirectory("Choose image folder"); //choose the folder
containing images to stitch
outputDir1 = getDirectory("Choose saving folder");//choose the folder for
resulting images
fileList1 = getFileList(inputDir1);
for(k=0; k<fileList1.length; k++) { // repeat this process till the
fileList1 ends and increment by one
if (endsWith(fileList1[k], "/")) {
file1 = fileList1[k];
print (inputDir1 + file1 + "is a path");
newlist=substring(fileList1[k], 0, lengthOf(fileList1[k])-4);////name for
using grid/stitching remove _01/
print(newlist + "is a newlist");
run("Grid/Collection stitching", "type=[Grid: snake by rows] order=[Left &
Up] grid_size_x=2 grid_size_y=2 tile_overlap=60 first_file_index_i=1
directory=inputDir1 + file1 file_names=newlist_{ii}.tif
output_textfile_name=TileConfiguration.txt fusion_method=[Linear Blending]
regression_threshold=0.80 max/avg_displacement_threshold=2.50
absolute_displacement_threshold=3.50 compute_overlap subpixel_accuracy
computation_parameters=[Save computation time (but use more RAM)]
image_output=[Fuse and display]");
}}
When i use this code, i got error:
Loading (0,0): D:\Fiji\Fiji.app\inputDir1\newlist_01.tif...cannot find
file: "inputDir\nelist_01.tif"-abort stitching
How can i make plugin to read the path and filenames?
I tried to use +"]" but it does not seem working.
I appreciate any suggestion.
Rui
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html______________________________________________________________________
The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.
______________________________________________________________________
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html